-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoystick_fun_cu_leds.ino
More file actions
71 lines (66 loc) · 1.49 KB
/
Copy pathjoystick_fun_cu_leds.ino
File metadata and controls
71 lines (66 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
int led1=9;
int led2=10;
int Rx=A1;
int Ry=A0;
int Sw=3;
int counter=1;
int buttonState=0;
int lastbuttonState=0;
int MappedRx;
int MappedRy;
void setup() {
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(Sw,INPUT_PULLUP);
pinMode(led1,OUTPUT);
pinMode(Rx,INPUT);
pinMode(Ry,INPUT);
Serial.begin(9600);
}
void loop() {
buttonState=digitalRead(Sw);
//Serial.println(buttonState);
Serial.println (" ");
Rx=analogRead(A1);
Ry=analogRead(A0);
//Serial.println(Rx);
//Serial.println(" ");
//Serial.println(Ry);
//Serial.print(" ");
MappedRx=map(Rx,0,990,0,255);
MappedRy=map(Ry,0,990,0,255);
//Serial.println ("this is Mapped ");
//Serial.println (" ");
//Serial.println(MappedRx);
//Serial.println (" ");
//Serial.println ("this is Mapped ");
//Serial.println (" ");
//Serial.println(MappedRy);
//Serial.println (" ");
//Serial.println ("n/ ");
//pt vizualizare si reparare
analogWrite(led1,MappedRx);
analogWrite(led2,MappedRy);
if ( buttonState !=lastbuttonState) {
if (buttonState==HIGH){
counter++;
}
delay(50);
}
lastbuttonState=buttonState;
if(counter>=3) {
Serial.println("merge");
counter=0;
analogWrite(led1,255);
analogWrite(led2,255);
delay(250);
analogWrite(led1,0);
analogWrite(led2,0);
delay(250);
}
else if (counter==1){
Serial.println("inchis");
analogWrite(led1,0);
analogWrite(led2,0);
}
}