Have you seen our new promotions? 15% flat discount on over 180 products!! Click here to see the items!

Start with Arduino - Zeroohm Arduino Training

Posted by Mohammed AlMheiri 23/10/2016 0 Comment(s) Microcontrollers,

Welcome to Zeroohm Arduino Training series. In this series of Arduino Training, Zeroohm will focus its efforts on helping the community learn more about Arduino fundamentals and basics starting with basic control of LED's, motors, sensors and utilizing of wirless communication. We hope that you find this useful, Please, leave a comment for any questions or comments or reviews!

We provide all our trainings for groups from schools, universities, public sector and private sector in Abu Dhabi, Dubai, Sharjah, Fujirah, RAK or anywhere in UAE. Please,click here to contact us directly for any training inquires.

We are also an authorized Arduino distributor for the UAE, Oman, Qatar, Saudi, Kuwait and Bahrain. We can provide you with any product of your choice. Please, contact us for inquires.

 

Our Arduino training series:

1. Start with Arduino - Zeroohm Arduino Training

2. Start with Arduino - Arduino with Motors and sensors

3. Start with Arduino - Wireless communication

4. How to setup Arduino with room temperature monitoring using LM36 sensor

 

Arduino Zeroohm workshops aim to let beginners get started with Arduino using Sparkfun Inventor Kit:
-    Understanding what is a Sparkfun Inventor Kit, how its components.
-    Learning how to use the breadboard.
-    Learning how to use the Sparkfun RedBoard, and the difference between analog and digital pins.
-    Understanding how to write Arduino code, and the use of each command.

 Experiment 1: Blinking an LED
A light-emitting diode (LED) is a semiconductor device that produces light from electricity.  LEDs last a long time and do not break easily compared to incandescent light bulbs. They can produce many different colours.
In this task you will control the switching of an LED through the RedBoard by the following steps:

1.    Connect the following Circuit using the shown components in Fig.1.


2.    Open Arduino IDE software and start writing the following code:
void setup()
{
  pinMode(13, OUTPUT);
}
void loop()
{
  digitalWrite(13, HIGH);               // Turn on the LED
  delay(1000);                                              // Wait for one second
  digitalWrite(13, LOW);                        // Turn off the LED
  delay(1000);                                       // Wait for one second
}
3.    Check that your code is correct and upload it to the RedBoard.
4.    Notice what happens to the LED.

 Discussion:

-    The Arduino IDE has two main functions, the setup () function and the loop () function. The setup () function is called when a sketch starts. It is used to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each power up or reset of the RedBoard.

-    After creating a setup () function, which initializes and sets the initial values, the loop () function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the RedBoard.

-    The controlling of the LED blinking is done through Digital Pin13; which the +ve side of the Led is connected to. We first configure Pin13 to be an output in the setup loop, pins configured as OUTPUT with pinMode () are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits.

-    By using the DigitalWrite() function the voltage of Pin13 will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

-    In order to notice the blinking of the LED we set a delay period between the two actions of turning the LED ON and OFF, we use the delay () function; which pauses the program for the amount of time (in milliseconds) specified as parameter, there are 1000 milliseconds in a second.


   Experiment 2: Potentiometer
A potentiometer is a simple knob that provides a variable resistance, which we can read into the RedBoard board as an analog value.
In this task you will control the blinking rate of LED through the RedBoard by the following steps:

1.    Connect the following Circuit using the shown components in Fig.2.


2.    Open Arduino IDE software and start writing the following code:
int sensorPin = 0;                // The potentiometer is connected to analog pin 0
int ledPin = 13;                  // The LED is connected to digital pin 13
void setup()
{    pinMode(ledPin, OUTPUT);  }
void loop()
{
 int sensorValue;
  sensorValue = analogRead(sensorPin);    
  digitalWrite(ledPin, HIGH);             // Turn the LED on
  delay(sensorValue);                            // Pause for sensorValue in milliseconds
  digitalWrite(ledPin, LOW);                  // Turn the LED off
  delay(sensorValue);                        // Pause for sensorValue in milliseconds
}

3.    Check that your code is correct and upload it to the RedBoard.
4.    Notice the change in the blinking rate of the LED when you vary the potentiometer.

 Discussion:

-    The potentiometer changes its resistance as it is turned. By using it as a "voltage divider", the RedBoard can sense the position of the knob, and use that value to control whatever you wish (like the blink rate of an LED, as we're doing in this task).

-    analogRead() function reads the value from the specified analog pin, the number of the analog input pin to read from 0 to 5 on most boards.

-    The blinking rate of the LED is controlled by using the delay() in which we applied the value of the sensorpin.

  Experiment 3: Push Buttons
A push-button is a switch in the shape of a small button or knob. When it is pushed it completes an electrical circuit that controls something. For example a doorbell rings when a person pushes a button, or numbers are displayed on a calculator.
In this task you will control the switching of LED through a push button using the RedBoard by the following steps:

1.    Connect the following Circuit using the shown components in Fig.3.


2.    Open Arduino IDE software and start writing the following code:
const int button1Pin = 2;              // pushbutton 1 pin
const int button2Pin = 3;              // pushbutton 2 pin
const int ledPin =  13;                    // LED pin
void setup()
{
  pinMode(button1Pin, INPUT);          // Set up the pushbutton pins to be an input:
  pinMode(button2Pin, INPUT);
  pinMode(ledPin, OUTPUT);                // Set up the LED pin to be an output:

}

void loop()
{
  int button1State, button2State;                       //variables to hold the pushbutton states

  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);
 
  if (((button1State == LOW) || (button2State == LOW))  // if we're pushing button 1 OR button 2
      && !                                                                        // AND we're NOT
      ((button1State == LOW) && (button2State == LOW)))    // pushing button 1 AND button 2
  {  digitalWrite(ledPin, HIGH);   }                               // turn the LED on
  else
  {  digitalWrite(ledPin, LOW);   }                         // turn the LED off         
}

3.    Check that your code is correct and upload it to the RedBoard.
4.    Notice what happens to the LED when you push the buttons.  

Discussion:

-    The const keyword stands for constant. It is a variable qualifier that modifies the behaviour of the variable, making a variable "read-only". This means that the variable can be used just as any other variable of its type, but its value cannot be changed. You will get a compiler error if you try to assign a value to a const variable.

-    Pins configured as INPUT with pinMode() are said to be in a high-impedance state. Pins configured as INPUT make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor.

-    The if() statement is the most basic of all programming control structures. It allows you to make something happen or not, depending on whether a given condition is true or not. There's also the else-if, where you can check a second condition if the first is false:

 Experiment 4: RGB LED
In an RGB LED there are three cathodes and one anode. Each cathode is connected to a single colour (red, green or blue) and the 16.7 million different colours are produced in that one single LED.
In this task you will switch a RGB LED in different colours by the following steps:

1.    Connect the following Circuit using the shown components in Fig.4.


2.    Open Arduino IDE software and start writing the following code:
const int RED_PIN = 9;
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;

void setup()
{
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
}

void loop()
{
  // Off (all LEDs off):
  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000);

  // Red (turn just the red LED on):
  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000);

  // Green (turn just the green LED on):
  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000);

  // Blue (turn just the blue LED on):
  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, HIGH);
  delay(1000);

  // Yellow (turn red and green on):
  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000);

  // Cyan (turn green and blue on):
  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, HIGH);
  delay(1000);

  // Purple (turn red and blue on):
  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, HIGH);
  delay(1000);

  // White (turn all the LEDs on):
  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, HIGH);
  delay(1000);
}
3.    Check that your code is correct and upload it to the RedBoard.
4.    Notice the colours of the LED.
    Experiment 5: Piezo Buzzer
A buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.
In this task you will vary the tone of the piezo buzzer by the following steps:

1.    Connect the following Circuit using the shown components in Fig.5.


2.    Open Arduino IDE software and start writing the following code:
const int buzzerPin = 9;
void setup()
{ }
void loop()
{
   tone(buzzerPin,100);
   delay(100);
   tone(buzzerPin,150);
   delay(100);   
   tone(buzzerPin,1000);
   delay(100);
}

3.    Check that your code is correct and upload it to the RedBoard.
4.    Notice the different tones of the buzzer.


Note: Zeroohm provides many different Arduino, Raspberry Pi, Soldering, tailor made trainings. Please contact us for any inquires.

If you like it, please share it! We hope to have as many people learn as possible.

 

Leave a Comment