Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.
|
projets:arduino_beginner [2019/08/22 21:44] stfablab |
projets:arduino_beginner [2019/10/15 15:23] (Version actuelle) stfablab |
||
|---|---|---|---|
| Ligne 25: | Ligne 25: | ||
| ===== Réalisation ===== | ===== Réalisation ===== | ||
| - | <!-- /* | + | <!-- --> |
| - | Variable, | + | |
| - | carrefour numérique@cité des sciences et de l'industrie, Paris | + | |
| - | With no warranty | + | |
| - | */ | + | |
| - | //run Serial Monitor | + | |
| - | void setup() { | + | |
| - | Serial.begin(9600); | + | |
| - | Serial.println("Hello !"); | + | |
| - | Serial.println(); | + | |
| - | int a = 10; Serial.print("Quand a=10 l'adresse de a vaut : "); Serial.println(a); | + | |
| - | int b = 100; Serial.print("Quand b=100 l'adresse de b vaut : "); Serial.println(b); | + | |
| - | int c = a + b; Serial.print("Quand c=a+b l'adresse de c vaut : "); Serial.println(c); | + | |
| - | b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut : "); Serial.println(b); | + | |
| - | b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut maintenant : "); Serial.println(b); | + | |
| - | b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut maintenant : "); Serial.println(b); | + | |
| - | c = a + b; Serial.print("Quand c=a+b l'adresse de c vaut maintenant : "); Serial.println(c); | + | |
| - | Serial.println(); | + | |
| - | Serial.println("Une variable est une adresse dont le contenu peut changer de valeur"); | + | |
| - | Serial.println(); | + | |
| - | } | + | |
| - | void loop() { | + | |
| - | // put your main code here, to run repeatedly: | + | |
| - | } --> | + | |
| /* | /* | ||
| Variable, | Variable, | ||
| Ligne 54: | Ligne 31: | ||
| With no warranty | With no warranty | ||
| */ | */ | ||
| - | //run Serial Monitor | + | |
| void setup() { | void setup() { | ||
| + | //run Serial Monitor | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| Serial.println("Hello !"); | Serial.println("Hello !"); | ||
| Ligne 81: | Ligne 59: | ||
| ===== Suites du projet ===== | ===== Suites du projet ===== | ||
| - | <!-- Binary&decimal Table | + | <!-- Binary&decimal Table, How to print just once into the loop, |
| Présenter ici les évolutions possibles du projet, les améliorations que vous aimeriez y apporter, etc. ... --> | Présenter ici les évolutions possibles du projet, les améliorations que vous aimeriez y apporter, etc. ... --> | ||
| - | Binary & decimal Table : | + | Toolkit : |
| /* | /* | ||
| Binary/Decimal table, | Binary/Decimal table, | ||
| Ligne 133: | Ligne 112: | ||
| } | } | ||
| } | } | ||
| + | |||
| + | /* | ||
| + | Counter, | ||
| + | carrefour numérique@cité des sciences et de l'industrie, Paris | ||
| + | With no warranty | ||
| + | */ | ||
| + | |||
| + | int counter = 0; | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | Serial.println("Hello !"); | ||
| + | Serial.println(); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | counter++; | ||
| + | Serial.print("Counter in decimal : "); | ||
| + | Serial.println(counter); | ||
| + | Serial.print("Counter in binary : "); | ||
| + | Serial.println(counter, BIN); | ||
| + | Serial.print("Counter in hexadecimal : "); | ||
| + | Serial.println(counter, HEX); | ||
| + | Serial.println(); | ||
| + | } | ||
| + | |||
| + | /*Masks, | ||
| + | How to get a bit : (x&(1<<i))!=0 | ||
| + | How to set a bit : x|(1<<i) | ||
| + | How to clear a bit : x&(~(1<<i)) | ||
| + | carrefour numérique@cité des sciences et de l'industrie, Paris | ||
| + | With no warranty | ||
| + | */ | ||
| + | |||
| + | int b = B11011101; | ||
| + | int c = 1; | ||
| + | int d = 2; | ||
| + | |||
| + | void setup() { | ||
| + | // put your setup code here, to run once: | ||
| + | Serial.begin(9600); | ||
| + | Serial.println("Hello!"); | ||
| + | Serial.println(); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | // put your main code here, to run repeatedly: | ||
| + | if (c != d) { | ||
| + | d = c; | ||
| + | Serial.print("a = "); Serial.println(a, BIN); | ||
| + | Serial.print("b = "); Serial.println(b, BIN); | ||
| + | Serial.println(); | ||
| + | (b & (1 << 7)) != 0; Serial.print("Keeping b bit n°8 : "); Serial.println((b & (1 << 7)) != 0, BIN); | ||
| + | (b & (1 << 6)) != 0; Serial.print("Keeping b bit n°7 : "); Serial.println((b & (1 << 6)) != 0, BIN); | ||
| + | (b & (1 << 5)) != 0; Serial.print("Keeping b bit n°6 : "); Serial.println((b & (1 << 5)) != 0, BIN); | ||
| + | (b & (1 << 4)) != 0; Serial.print("Keeping b bit n°5 : "); Serial.println((b & (1 << 4)) != 0, BIN); | ||
| + | (b & (1 << 3)) != 0; Serial.print("Keeping b bit n°4 : "); Serial.println((b & (1 << 3)) != 0, BIN); | ||
| + | (b & (1 << 2)) != 0; Serial.print("Keeping b bit n°3 : "); Serial.println((b & (1 << 2)) != 0, BIN); | ||
| + | (b & (1 << 1)) != 0; Serial.print("Keeping b bit n°2 : "); Serial.println((b & (1 << 1)) != 0, BIN); | ||
| + | (b & (1 << 0)) != 0; Serial.print("Keeping b bit n°1 : "); Serial.println((b & (1 << 0)) != 0, BIN); | ||
| + | Serial.println(); | ||
| + | b = b | (1 << 5); Serial.println("Setting b bit n°6 with 1 : "); Serial.println(b, BIN); | ||
| + | Serial.println(); | ||
| + | b = b & (~(1 << 3)); Serial.println("Clearing b bit n°4 with 0 : "); Serial.println(b, BIN); | ||
| + | } | ||
| + | } | ||
| + | |||
| ===== Photos ===== | ===== Photos ===== | ||
| <!-- Quelques photos du rendu final du projet, mais aussi si c'est possible des differentes etapes si elle n'ont pas déja été documentées visuellement --> | <!-- Quelques photos du rendu final du projet, mais aussi si c'est possible des differentes etapes si elle n'ont pas déja été documentées visuellement --> | ||