Differences

This shows you the differences between two versions of the page.

Link to this comparison view

info2:laboratoare:lab2en [2020/03/03 12:39]
liviu.moraru created
info2:laboratoare:lab2en [2020/03/03 12:53] (current)
ioana_maria.culic
Line 2: Line 2:
  
 ===== Purpose ===== ===== Purpose =====
-  * familiarity ​with operations related to arduino ​pins +  * Get familiar ​with operations related to Arduino ​pins 
-  * familiarity ​with the basic concepts of programming+  * Get familiar ​with the basic concepts of programming
  
 ===== Keywords ===== ===== Keywords =====
Line 27: Line 27:
  
 ==== Arrays ==== ==== Arrays ====
-Arrays are more intelligent ​variables of a certain size that can store a string ​of values ​​​of each type above. Example: ​+Arrays are complex ​variables of a certain size that can store a list of values. Example: ​
 <code c variabile.c>​ <code c variabile.c>​
  
Line 37: Line 37:
       int arr2[] = { 1,​2,​3,​4,​5,​6};​       int arr2[] = { 1,​2,​3,​4,​5,​6};​
       char arr3[] = {'​a',​ '​b',​ '​c',​ '​d'​};​       char arr3[] = {'​a',​ '​b',​ '​c',​ '​d'​};​
-      char arr4[6] = "salut";+      char arr4[6] = "hello";
       return 0;       return 0;
 } }
Line 43: Line 43:
    
 ==== If - Else ==== ==== If - Else ====
-The if statement is a conditional sentence used to execute instructions ​according to certain conditions if-else construction translates to "if - otherwise":​+The if statement is a conditional sentence used to execute instructions ​based on certain conditions. The if-else construction translates to "if - otherwise":​
  
 <code c if_else.c>​ <code c if_else.c>​
Line 54: Line 54:
       if (a == 10) { //if a is equal to 10       if (a == 10) { //if a is equal to 10
           // do operations when a is 10           // do operations when a is 10
-      } else { // Altfel+      } else { // Else
           // do operations when a is different from 10           // do operations when a is different from 10
       }       }
Line 61: Line 61:
 </​code>​ </​code>​
 ==== For ==== ==== For ====
-The for structure is a repetitive structure ​depending ​on a condition. ​Way of ussage:+The for structure is a repetitive structure ​dependent ​on a condition. ​Usage:
 <code c for.c> <code c for.c>
  
Line 92: Line 92:
       printf("​%d\n",​ arr[2]); // show 3       printf("​%d\n",​ arr[2]); // show 3
                
-      for (i = 0; i < 9; i++) { // the positions in arraystart ​from 0!!+      for (i = 0; i < 9; i++) { // the positions in arrays start from 0!!
           ​           ​
           sum = sum + arr[i]; // the sum of all the elements in the array           sum = sum + arr[i]; // the sum of all the elements in the array
Line 122: Line 122:
 </​code>​ </​code>​
 ===== Arduino pins operations ===== ===== Arduino pins operations =====
-To use the pins of an arduino ​we need to set the way we want to use them (INPUT/​OUTPUT). Example: ​+To use the pins of the Arduino, ​we need to set the way we want to use them (INPUT/​OUTPUT). Example: ​
  
 <code arduino.c>​ <code arduino.c>​
Line 133: Line 133:
 </​code>​ </​code>​
  
-If we set a pin to OUTPUT mode, we can now output voltage to this pin using digitalWrite. Example:+If we set a pin to OUTPUT mode, we can now output voltage to this pin using digitalWrite(). Example:
  
 <code arduino.c>​ <code arduino.c>​
Line 150: Line 150:
 ===== Exercises ===== ===== Exercises =====
 All exercises will be performed on[[https://​www.tinkercad.com/​| Tinkercad]] All exercises will be performed on[[https://​www.tinkercad.com/​| Tinkercad]]
-  - Using an **ARDUINO**,​ a **LED** and a **220 ohm RESISTOR**, turn on and off led at fixed interval of time+  ​- Use an ammeter to measure the voltage on GPIO pin number 3. Set the pin to HIGH and LOW and notice how the values change. 
-  - Simulate a car traffic light and a pedestrian traffic light to be synchronized. The traffic lights will be implemented using LEDs and will iterate an array.  +  ​- Using an **ARDUINO**,​ a **LED** and a **220 ohm RESISTOR**, turn on the LED (don't use GPIO pins), then measure the current ​and the voltage on that circuit. 
-  - Connect to an **ARDUINO** a **7 SEGMENT DISPLAY** and using helper functions, display each number on the display.+  - Using an **ARDUINO**, ​**LED** and **220 ohm RESISTOR**, make the LED blink. Solve this exercise in two ways.  
 +  - Simulate a car traffic light and a pedestrian traffic light to be synchronized. The traffic lights will be implemented using LEDs and will iterate an array. Solve this exercise in two ways
 +  - Connect to an **ARDUINO** a **7 SEGMENT DISPLAY** and using helper functions, display each number on the display. Solve this exercise in two ways: use a common anode 7 segment display, then a common cathode one. 
 +  - Using the 7 segment display implement a counter that displays the numbers from 0 to 9.
 {{:​info2:​laboratoare:​arduino-7-segment-display.png?​200|100}} {{:​info2:​laboratoare:​arduino-7-segment-display.png?​200|100}}
info2/laboratoare/lab2en.1583231956.txt.gz · Last modified: 2020/03/03 12:39 by liviu.moraru
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0