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/21 10:12]
stfablab créée
projets:arduino_beginner [2019/10/15 15:23] (Version actuelle)
stfablab
Ligne 16: Ligne 16:
  
 <!-- Débuter avec Arduino --> <!-- Débuter avec Arduino -->
 +Débuter avec Arduino
  
 ===== Conception ===== ===== Conception =====
  
 <!-- Exemple à la compréhension des variables --> <!-- Exemple à la compréhension des variables -->
 +Exemple à la compréhension des variables
  
 ===== 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 ===== ===== 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 -->
 +Comprendre qu'une variable est une adresse dont le contenu peut changer de valeur
  
 ===== Suites du projet ===== ===== Suites du projet =====
  
-<!-- Présenter ici les évolutions possibles du projet, les améliorations que vous aimeriez y apporter, etc. ... -->+<!-- 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 :
 +
 +/*
 +  Binary/Decimal table,
 +  carrefour numérique@cité des sciences et de l'industrie, Paris
 +  With no warranty
 +*/
 +
 +void setup() {
 +  Serial.begin(9600);
 +  Serial.println("Hello !");
 +  Serial.println();
 +
 +  for (int x = 0; x < 256; x++) {
 +    Serial.print("Bit ");
 +    Serial.print(x, BIN);
 +    Serial.print(" is ");
 +    Serial.print(x, DEC);
 +    Serial.println(" in decimal ");
 +  }
 +  Serial.println();
 +}
 +
 +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();
 +}
 +
 +void loop() {
 +  if (a != b) {
 +    for (int i = 0; i < 1; i++) {
 +      Serial.println("Just One Print In The Loop");
 +      b = a;
 +    }
 +  }
 +}
 +
 +/*
 +  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 =====
projets/arduino_beginner.1566375172.txt.gz · Dernière modification: 2019/08/21 10:12 par stfablab