So, this is my second project with arduino. I'm trying to make something similar to a clap hand games, but with 8 analog sensors, 2 in the palm of my hand, 2 on the back of my hand, 2 in my friend's palm hand,2 on the back of my hand.I'm using 2 processors, one for write(with me) and one for read(with my friend),each sensor will be represented by one color,for example, the red on my hand, need to touch with the red on his hand, and if we touch different colours, my buzzer will play a specific song alerting the mistake.
But i am having some troubling with the analog reading value, i am testing this programs here: obs i am using lilypad
Write:
const int red = A4;
void setup() { pinMode(vermelho,OUTPUT); }
void loop () { analogWrite(vermelho, 20); }
Read:
const int red = A4;
int val = 20;
void setup() {
pinMode(vermelho,INPUT);
Serial.begin(9600); }
void loop () {
Serial.println(analogRead(val)); }
I want my write code to pass the value 20 and my read command to read 20 for red color, but my read value is 0 if the write value is under 127, and if its higher then 127 the read value is 1023, i wish somebody could help me, i need to define 4 colours(red,blue,green and yellow) with 4 differents value for write and read, and if they touch different coloursm the song will alert the mistake.