diff --git a/README.md b/README.md index 98a42ea..253ea95 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,27 @@ Arduino's code is something like: ```c int joystickPin = A0; int getPushedButton(int joystickPin){ - int val=analogRead(joystickPin); + /* + * retourne le numéro du boutton appuyé + * bouton | numéro | mesure analogRead + * aucun | 0 | 1024 + * haut | 1 | 19 + * bas | 2 | 8 + * gauche: | 3 | 54 + * droite: | 4 | 705 + * bas2 : | 5 | 511 + * haut2: | 6 | 183 + */ + int val=analogRead(joystickPin); + if(val > 1000){ return 0; }else if (val > 650){ return 4; }else if(val > 450){ - return 6; + return 5; }else if(val > 120){ - return 5; + return 6; }else if(val > 45){ return 3; }else if(val > 15){ @@ -21,6 +33,19 @@ int getPushedButton(int joystickPin){ return 2; } } + + + +void setup() { + Serial.begin(9600); +} + + +void loop() { + int button=getPushedButton(A0); + Serial.println(button); + delay(500); +} ``` Adapt limit values if you use differents resistors than mines.