The purpose of the week is to measure something: add a sensor to a microcontroller board that I have designed and read it
In link with my project i decided to test system that can help to detect proximity or vibration on climbing hold.



#include
#define RX 1
#define TX 2
SoftwareSerial MySerial(RX,TX);
int SensorPin = A2;
int LedPin = 3;
int sensorValue = 0;
int sensorValueLEDON =0;
int sensorValueLEDOFF = 0;
void setup() {
pinMode(SensorPin,INPUT);
pinMode(LedPin,OUTPUT);
MySerial.begin(9600);
}
void loop() {
digitalWrite(LedPin,HIGH);
sensorValueLEDOFF = analogRead(SensorPin);
MySerial.print("valueOFF");
MySerial.println(sensorValueLEDOFF);
delay(10);
digitalWrite(LedPin,LOW);
sensorValueLEDON = analogRead(SensorPin);
delay(10);
MySerial.print("valueON");
MySerial.println(sensorValueLEDON);
sensorValue = sensorValueLEDON - sensorValueLEDOFF;
MySerial.print("value");
MySerial.println(sensorValue);
if (sensorValue >= 70) {
MySerial.print("Contact");
}
}




#include
#define RX 1
#define TX 2 /* only TX is connected on the board*/
SoftwareSerial MySerial(RX,TX);
int SensorPin1 = A2;
int SensorPin2 = A3;
int sensorValue1 = 0;
int sensorValue2 = 0;
void setup() {
pinMode(SensorPin1,INPUT); /* init pin and serial */
pinMode(SensorPin2,INPUT);
MySerial.begin(9600);
}
void loop() {
sensorValue1 = analogRead(SensorPin1); /* read value ADC2 */
delay(10);
MySerial.print("Piezo 1 : ");
MySerial.print(sensorValue1); /*send value on serial*/
sensorValue2 = analogRead(SensorPin2); /* read value on ADC3 */
delay(10);
MySerial.print(" Piezo 2 : ");
MySerial.println(sensorValue2); /* send value to serial*/
}
you can find the design files on my
github repository :