45 lines
985 B
Plaintext
45 lines
985 B
Plaintext
|
const int analogInPin0 = 0; // Analog input pin that the potentiometer is attached to
|
||
|
const int analogInPin1 = 3; // Analog input pin that the potentiometer is attached to
|
||
|
|
||
|
int sensorValue = 0; // value read from the pot
|
||
|
int flag0 = 0;
|
||
|
int flag1 = 0;
|
||
|
|
||
|
void setup() {
|
||
|
// initialize serial communications at 9600 bps:
|
||
|
Serial.begin(9600);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
// read the analog in value:
|
||
|
sensorValue = analogRead(analogInPin0);
|
||
|
if ((sensorValue>200)&&(!flag0))
|
||
|
{
|
||
|
flag0=1;
|
||
|
Serial.print(11,BYTE);
|
||
|
delay(200);
|
||
|
Serial.print(10,BYTE);
|
||
|
}
|
||
|
else if ((sensorValue<200)&&(flag0))
|
||
|
{
|
||
|
flag0=0;
|
||
|
//Serial.print(11,BYTE);
|
||
|
}
|
||
|
|
||
|
sensorValue = analogRead(analogInPin1);
|
||
|
if ((sensorValue>200)&&(!flag1))
|
||
|
{
|
||
|
flag1=1;
|
||
|
Serial.print(21,BYTE);
|
||
|
delay(200);
|
||
|
Serial.print(20,BYTE);
|
||
|
}
|
||
|
else if ((sensorValue<200)&&(flag1))
|
||
|
{
|
||
|
flag1=0;
|
||
|
//Serial.print(21,BYTE);
|
||
|
}
|
||
|
|
||
|
delay(10);
|
||
|
}
|