Input Devices

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.

IRDetection board

I would like to detect proximity, I can use the Neil's synchronous detection spread spectrum board but I need to detect proximity also on holds that are light off, so I can't use normal led. So based on the same schematic I replace the Led and the phototransistor by ones who work in Infrared spectrum. These 2 componants won't be directly on the board but replaced by a 2x2 PIN connector. The lED and the PhotoTransistor will be put inside the hold.
Design
Trace
CutOut

IRBoard
I use the Arduino IDE to program it, for ATtiny the basic serial command doesn't work, you have to use the "SoftwareSerial" library.
following the code of the IRDetect.ino
      
#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");   
  }

}
     
     
     

Vibration board

I would like to detect vibration when some touch the hold, I decide tu use Piezo disk which transform vibration into electricity. As there is 2 Pin free I will connect 2 piezo by Tiny 45. Same as the other board, these 2 piezo won't be directly on the board but replaced by a 2x2 PIN connector. The piezo will be put on the backside of the hold.
Design
Trace


PiezoBoard
I use the Arduino IDE to program it, for ATtiny the basic serial command doesn't work, you have to use the "SoftwareSerial" library.
following the code of the PiezoDetect.ino
      
#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 :github