Stap 5: Gegevensinvoer en Arduino verbinding
mannelijke headers zodat u hen gemakkelijk op de Arduino aansluiten kunt (zie afbeelding
in het Rode plein)
Later we aansluiten de pennen aan de Arduino gekenmerkt door de
geel vierkant
That's it! Volg bulken de arduino-code. Veel plezier!
Selecteer de invoer pin voor de photosensor
int photo0 = 0;
int photo1 = 1;
int photo2 = 2;
int photo3 = 3;
int photo4 = 4;
int photo5 = 5;
variabele de waarde afkomstig van de sensor opslaan
int val0 = 0;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;
digitale uitgang
int out13 = 13;
int out12 = 12;
int out11 = 11;
int out10 = 10;
int out9 = 9;
int out8 = 8;
VOID Setup {}
Serial.begin(9600);
pinMode (out13, OUTPUT);
digitalWrite(out13,LOW);
pinMode (out12, OUTPUT);
digitalWrite(out12,LOW);
pinMode (out11, OUTPUT);
digitalWrite(out11,LOW);
pinMode (out10, OUTPUT);
digitalWrite(out10,LOW);
pinMode (out9, OUTPUT);
digitalWrite(out9,LOW);
pinMode (out8, OUTPUT);
digitalWrite(out8,LOW);
}
void loop {}
val0 = analogRead(photo0);
val1 = analogRead(photo1);
val2 = analogRead(photo2);
val3 = analogRead(photo3);
val4 = analogRead(photo4);
val5 = analogRead(photo5);
if(val4>400) {}
digitalWrite(out13,HIGH);
Serial.println("pressed!");
} else if(val4<350) {}
digitalWrite(out13,LOW);
}
if(val3>600) {}
digitalWrite(out12,HIGH);
Serial.println("pressed!");
} else if(val3<550) {}
digitalWrite(out12,LOW);
}
if(val2>900) {}
digitalWrite(out11,HIGH);
Serial.println("pressed!");
} else if(val2<850) {}
digitalWrite(out11,LOW);
}
if(val0>400) {}
digitalWrite(out9,HIGH);
Serial.println("pressed!");
} else if(val0<350) {}
digitalWrite(out9,LOW);
}
if(val5>630) {}
digitalWrite(out8,HIGH);
Serial.println("pressed!");
} else if(val5<615) {}
digitalWrite(out8,LOW);
}
}