Outils d'utilisateurs

Outils du Site


projets:arduino_beginner

Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

projets:arduino_beginner [2019/08/22 21:39]
stfablab
projets:arduino_beginner [2019/10/15 15:23] (Version actuelle)
stfablab
Ligne 25: Ligne 25:
 ===== Réalisation ===== ===== Réalisation =====
  
-<!-- /*+<!-- --> 
 +/*
   Variable,   Variable,
   carrefour numérique@cité des sciences et de l'industrie, Paris   carrefour numérique@cité des sciences et de l'industrie, Paris
   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 48: Ligne 50:
 void loop() { void loop() {
   // put your main code here, to run repeatedly:   // put your main code here, to run repeatedly:
-} -->+} 
 + 
 +===== Difficultés rencontrées ===== 
 + 
 +<!-- Comprendre qu'une variable est une adresse dont le contenu peut changer de valeur --> 
 +Comprendre qu'une variable est une adresse dont le contenu peut changer de valeur 
 + 
 +===== Suites du projet ===== 
 + 
 +<!-- 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. ... --> 
 + 
 +Toolkit : 
 /* /*
-  Variable,+  Binary/Decimal table,
   carrefour numérique@cité des sciences et de l'industrie, Paris   carrefour numérique@cité des sciences et de l'industrie, Paris
   With no warranty   With no warranty
 */ */
-//run Serial Monitor+
 void setup() { void setup() {
   Serial.begin(9600);   Serial.begin(9600);
   Serial.println("Hello !");   Serial.println("Hello !");
   Serial.println();   Serial.println();
-  int 10Serial.print(&quot;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); +  for (int 0&lt256x++{ 
-  int c = a + b; Serial.print("Quand c=a+b l'adresse de c vaut : "); Serial.println(c); +    Serial.print("Bit "); 
-  b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut : "); Serial.println(b); +    Serial.print(x, BIN); 
-  b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut maintenant : "); Serial.println(b); +    Serial.print(" is "); 
-  b = b - a; Serial.print("Quand b=b-a l'adresse de b vaut maintenant : "); Serial.println(b); +    Serial.print(x, DEC); 
-  c = a + b; Serial.print("Quand c=a+b l'adresse de c vaut maintenant : "); Serial.println(c);+    Serial.println(" in decimal "); 
 +  }
   Serial.println();   Serial.println();
-  Serial.println("Une variable est une adresse dont le contenu peut changer de valeur");+
 + 
 +void loop() { 
 +
 + 
 + 
 +/* 
 +  How to print just once into the loop, 
 +  carrefour numérique@cité des sciences et de l'industrie, Paris 
 +  With no warranty 
 +*/ 
 + 
 +int a = 0; 
 +int b = 1; 
 + 
 +void setup() { 
 +  Serial.begin(9600); 
 +  Serial.println("Hello !");
   Serial.println();   Serial.println();
 } }
 +
 void loop() { void loop() {
-  // put your main code here, to run repeatedly:+  if (a != b) { 
 +    for (int i = 0; i < 1; i++) { 
 +      Serial.println("Just One Print In The Loop"); 
 +      b = a; 
 +    } 
 +  }
 } }
  
-===== Difficultés rencontrées =====+/* 
 +  Counter, 
 +  carrefour numérique@cité des sciences et de l'industrie, Paris 
 +  With no warranty 
 +*/
  
-<;!-- Comprendre qu'une variable est une adresse dont le contenu peut changer de valeur --> +int counter = 0;
-Comprendre qu'une variable est une adresse dont le contenu peut changer de valeur+
  
-===== Suites du projet =====+void setup() { 
 +  Serial.begin(9600); 
 +  Serial.println("Hello !"); 
 +  Serial.println(); 
 +}
  
-&lt;!-- Présenter ici les évolutions possibles du projet, les améliorations que vous aimeriez y apporter, etc. ... --&gt;+void loop() { 
 +  counter++; 
 +  Serial.print(&quot;Counter in decimal : "); 
 +  Serial.println(counter); 
 +  Serial.print("Counter in binary : "); 
 +  Serial.println(counter, BIN); 
 +  Serial.print(&quot;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 =====
projets/arduino_beginner.1566502775.txt.gz · Dernière modification: 2019/08/22 21:39 par stfablab