Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x;
- int y;
- void setup()
- {
- Serial.begin(9600);
- pinMode(8,OUTPUT);
- pinMode(9,OUTPUT);
- pinMode(10,OUTPUT);
- pinMode(11,OUTPUT);
- pinMode(12,OUTPUT);
- pinMode(A0, INPUT);
- pinMode(A1, INPUT);
- }
- void loop()
- {
- x=analogRead(A0);
- y=analogRead(A1);
- Serial.println("x y");
- Serial.print(x);
- Serial.print(" ");
- Serial.println(y);
- if(x>550){
- digitalWrite(8,HIGH);
- digitalWrite(9,LOW);
- digitalWrite(10,LOW);
- digitalWrite(11,LOW);
- digitalWrite(12,LOW);
- }
- else if(y>525){
- digitalWrite(8,LOW);
- digitalWrite(9,LOW);
- digitalWrite(10,LOW);
- digitalWrite(11,HIGH);
- digitalWrite(12,LOW);
- }
- else if(x<500){
- digitalWrite(8,LOW);
- digitalWrite(9,HIGH);
- digitalWrite(10,LOW);
- digitalWrite(11,LOW);
- digitalWrite(12,LOW);
- }
- else if(y<475){
- digitalWrite(8,LOW);
- digitalWrite(9,LOW);
- digitalWrite(10,LOW);
- digitalWrite(11,LOW);
- digitalWrite(12,HIGH);
- }
- else if(x>500 && x<550){
- digitalWrite(8,LOW);
- digitalWrite(9,LOW);
- digitalWrite(10,HIGH);
- digitalWrite(11,LOW);
- digitalWrite(12,LOW);
- }
- delay(100);
- }
Add Comment
Please, Sign In to add comment