Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,147,836 members, 7,798,814 topics. Date: Tuesday, 16 April 2024 at 10:47 AM

Free Arduino Tutorials - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Free Arduino Tutorials (11126 Views)

Arduino,raspberry Pi,sensors Etc / Arduino Programming Boards, Shields, And Sensors Purchases / Free Arduino Tutorials (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Free Arduino Tutorials by princejude(m): 8:07pm On Jan 10, 2015
What is arduino ?

Arduino is an open-source electronics prototyping platform based on flexible, easy-to use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language and the Arduino Development Environment. Arduino projects can be stand-alone, or they can communicate with software running on a computer.

There are plenty of other microcontrollers available. So you may be asking, why choose the Arduino? Arduino really simplifies the process of building projects on a microcontroller making it a great platform for amateurs. You can easily start working on one with no previous electronics experience.

In addition to Arduino’s simplicity, it is also inexpensive, cross-platform and open source. The Arduino is based on Atmel’s ATMEGA328 and ATMEGA168 microcontrollers.

Arduino Software

Software programs, called sketches, are created on a computer using the Arduino integrated development environment (IDE). The IDE enables you to write and edit code and convert this code into instructions that Arduino hardware understands.
The IDE also transfers those instructions to the Arduino board (a process called uploading).




Arduino Hardware

The Arduino board is where the code you write is executed. The board can only control and respond to electricity, so specific components are attached to it to enable it to interact with the real world. These components can be sensors, which convert some aspect of the physical world to electricity so that the board can sense it, or actuators, which get electricity from the board and convert it into something that changes the world. Examples of sensors include switches, accelerometers, and ultrasound distance sensors. Actuators are things like lights and LEDs, speakers, motors, and displays.

There have been a number of Arduino versions, all based on an 8-bit Atmel AVR reduced instruction set computer (RISC) microprocessor. The first board was based on the ATmega8 running at a clock speed of 16 MHz with 8 KB flash memory; later boards such as the Arduino NG plus and the Diecimila (Italian for 10,000) used the
ATmega168 with 16 KB flash memory. The most recent Arduino versions, Duemilanove and Uno, use the ATmega328 with 32 KB flash memory and can switch automatically between USB and DC power. For projects requiring more I/O and memory, there’s the Arduino Mega1280 with 128 KB memory or the more recent Arduino Mega2560 with 256 KB memory.
The boards have 14 digital pins, each of which can be set as either an input or output, and six analog inputs. In addition, six of the digital pins can be programmed to provide a pulse width modulation (PWM) analog output. A variety of communication protocols are available, including serial, serial peripheral interface bus (SPI), and I2C/ TWI. Included on each board as standard features are an in-circuit serial programming (ICSP) header and reset button.



Project 1: Creating a blinking LED wave

Let’s put some LEDs and resistors to work. In this project, we’ll use five LEDs to create a kind of wavelike light pattern.

The Hardware

Here’s what you’ll need to create this project:

>> Five LEDs
>> Five 560W resistors
>> One breadboard
>> Various connecting wires
>> Arduino and USB cable

We will connect the LEDs to digital pins 2 through 6 via the 560-ohm
current-limiting resistors.

The Sketch

Now for our sketch. Enter this code into the IDE:


// Project 1 - Creating a Blinking LED Wave

void setup()
{
pinMode(2, OUTPUT); // LED 1 control pin is set up as an output
pinMode(3, OUTPUT); // same for LED 2 to LED 5
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop()
{
digitalWrite(2, HIGH); // Turn LED 1 on
delay(500); // wait half a second
digitalWrite(2, LOW); // Turn LED 1 off
digitalWrite(3, HIGH); // and repeat for LED 2 to 5
delay(500);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(500);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay(500);
digitalWrite(3, LOW);
// the loop() will now loop around and start from the top again
}

In void setup() the digital I/O pins are set to outputs, because we want them to send current to the LEDs on demand. We specify when to turn on each LED using the digitalWrite() function in the void loop() section of the sketch.

Project 2: Repeating with for loops

to be contd.... or check here: http://www.jutronix.com/tutorials/arduino-tutorial/

1 Like

Re: Free Arduino Tutorials by AAinEqGuinea: 5:58pm On Jan 11, 2015
Nice post... I use pi
Re: Free Arduino Tutorials by princejude(m): 1:21pm On Jan 12, 2015
AAinEqGuinea:
I use pi
What pi ?
Re: Free Arduino Tutorials by 9free(m): 3:27pm On Jan 12, 2015
princejude:

What pi ?
Raspberry Pi grin

2 Likes

Re: Free Arduino Tutorials by princejude(m): 3:32pm On Jan 12, 2015
9free:

Raspberry Pi grin

Oh! ok do you have the board?
Re: Free Arduino Tutorials by 9free(m): 5:58pm On Jan 12, 2015
princejude:


Oh! ok do you have the board?

I currently do not have the board. But it's readily available in th market.

1 Like

Re: Free Arduino Tutorials by AAinEqGuinea: 12:09am On Jan 13, 2015
princejude:

What pi ?

Raspberry pi



Have a clusters of them.

but I'm sure you're aware, it doesnt matter what you use.
Re: Free Arduino Tutorials by internetpo(m): 8:12am On Jan 15, 2015
between raspberry Pi and arudinuio. which is better?
Re: Free Arduino Tutorials by Leopantro: 11:35am On Jan 15, 2015
AAinEqGuinea:


Raspberry pi



Have a clusters of them.

but I'm sure you're aware, it doesnt matter what you use.

how much do you sell your raspberry pi and where are you located?
Re: Free Arduino Tutorials by Leopantro: 1:04pm On Jan 15, 2015
princejude:
What is arduino ?

Arduino is an open-source electronics prototyping platform based on flexible, easy-to use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language and the Arduino Development Environment. Arduino projects can be stand-alone, or they can communicate with software running on a computer.

There are plenty of other microcontrollers available. So you may be asking, why choose the Arduino? Arduino really simplifies the process of building projects on a microcontroller making it a great platform for amateurs. You can easily start working on one with no previous electronics experience.

In addition to Arduino’s simplicity, it is also inexpensive, cross-platform and open source. The Arduino is based on Atmel’s ATMEGA328 and ATMEGA168 microcontrollers.

Arduino Software

Software programs, called sketches, are created on a computer using the Arduino integrated development environment (IDE). The IDE enables you to write and edit code and convert this code into instructions that Arduino hardware understands.
The IDE also transfers those instructions to the Arduino board (a process called uploading).




Arduino Hardware

The Arduino board is where the code you write is executed. The board can only control and respond to electricity, so specific components are attached to it to enable it to interact with the real world. These components can be sensors, which convert some aspect of the physical world to electricity so that the board can sense it, or actuators, which get electricity from the board and convert it into something that changes the world. Examples of sensors include switches, accelerometers, and ultrasound distance sensors. Actuators are things like lights and LEDs, speakers, motors, and displays.

There have been a number of Arduino versions, all based on an 8-bit Atmel AVR reduced instruction set computer (RISC) microprocessor. The first board was based on the ATmega8 running at a clock speed of 16 MHz with 8 KB flash memory; later boards such as the Arduino NG plus and the Diecimila (Italian for 10,000) used the
ATmega168 with 16 KB flash memory. The most recent Arduino versions, Duemilanove and Uno, use the ATmega328 with 32 KB flash memory and can switch automatically between USB and DC power. For projects requiring more I/O and memory, there’s the Arduino Mega1280 with 128 KB memory or the more recent Arduino Mega2560 with 256 KB memory.
The boards have 14 digital pins, each of which can be set as either an input or output, and six analog inputs. In addition, six of the digital pins can be programmed to provide a pulse width modulation (PWM) analog output. A variety of communication protocols are available, including serial, serial peripheral interface bus (SPI), and I2C/ TWI. Included on each board as standard features are an in-circuit serial programming (ICSP) header and reset button.



Project 1: Creating a blinking LED wave

Let’s put some LEDs and resistors to work. In this project, we’ll use five LEDs to create a kind of wavelike light pattern.

The Hardware

Here’s what you’ll need to create this project:

>> Five LEDs
>> Five 560W resistors
>> One breadboard
>> Various connecting wires
>> Arduino and USB cable

We will connect the LEDs to digital pins 2 through 6 via the 560-ohm
current-limiting resistors.

The Sketch

Now for our sketch. Enter this code into the IDE:


// Project 1 - Creating a Blinking LED Wave

void setup()
{
pinMode(2, OUTPUT); // LED 1 control pin is set up as an output
pinMode(3, OUTPUT); // same for LED 2 to LED 5
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop()
{
digitalWrite(2, HIGH); // Turn LED 1 on
delay(500); // wait half a second
digitalWrite(2, LOW); // Turn LED 1 off
digitalWrite(3, HIGH); // and repeat for LED 2 to 5
delay(500);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(500);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
delay(500);
digitalWrite(3, LOW);
// the loop() will now loop around and start from the top again
}

In void setup() the digital I/O pins are set to outputs, because we want them to send current to the LEDs on demand. We specify when to turn on each LED using the digitalWrite() function in the void loop() section of the sketch.

Project 2: Repeating with for loops

to be contd.... or check here: http://www.jutronix.com/tutorials/arduino-tutorial/


sorry for quoting the whole post.
how much will it cost to create a unit of this, can it be made to run off batteries and can the number of LEDs be increased?
Re: Free Arduino Tutorials by princejude(m): 4:33pm On Jan 15, 2015
Leopantro:



sorry for quoting the whole post.
how much will it cost to create a unit of this, can it be made to run off batteries and can the number of LEDs be increased?

The Arduino board is N5000. You can increase the number of LEDs
Re: Free Arduino Tutorials by sisqology(m): 4:58pm On Jan 15, 2015
Now following, I need for a project.
Re: Free Arduino Tutorials by LordRahl001: 3:23pm On Jan 16, 2015
princejude:


The Arduino board is N5000. You can increase the number of LEDs
and how much is the whole starter kit and pls where can i get it in Lagos
Re: Free Arduino Tutorials by princejude(m): 3:56pm On Jan 16, 2015
LordRahl001:
and how much is the whole starter kit and pls where can i get it in Lagos
Yo can get a starter kit of N7000 or advance kit from N12000 to N20000. The price depends on its content. Am not in Lagos but if you want me to send it to you, you can add N2000 shipment fee
Re: Free Arduino Tutorials by LordRahl001: 8:58am On Jan 17, 2015
princejude:
Yo can get a starter kit of N7000 or advance kit from N12000 to N20000. The price depends on its content. Am not in Lagos but if you want me to send it to you, you can add N2000 shipment fee
thanks for the swift response!! will get across as soon as I can!!
Re: Free Arduino Tutorials by AAinEqGuinea: 10:58am On Jan 17, 2015
Leopantro:


how much do you sell your raspberry pi and where are you located?

Pis are about $35 USD each and, in many respects, worth it.. but we're I'm not here to highlight Pi (for now), Arduino time! which tend to be more agile. Thanks for posting.
Re: Free Arduino Tutorials by princejude(m): 4:20pm On Jan 17, 2015
Back to tutorial...

Project 2: Using for loops

When designing a sketch, you’ll often repeat the same function. You could simply copy and paste the function to duplicate it in a sketch, but that’s inefficient and a waste of your Arduino’s program memory.Instead, you can use for loops. The benefit of using a for loop is that you can determine how many times the code inside the loop will repeat.To see how a for loop works, enter the following code as a new sketch:



// Project 2 - Repeating with for Loops

int d = 100;

void setup()
{
for(int a = 2; a < 7; a++)
pinMode (a, OUTPUT);
}

void loop()
{
for ( int b = 2; b < 7 ; b++ )
{
digitalWrite(b, HIGH);
delay(d);
digitalWrite(b, LOW);
delay(d);
}
}


The for loop will repeat the code within the curly brackets beneath it as long as some condition is true. Here, we have used two new integer variables, a and b, which starts with the value 2. Every time the code is executed, the a++ will add 1 to the value of a. The loop will continue in this fashion while the value of a is less than 7 (the condition). Once it is equal to or greater than 7, the Arduino moves on and continues with whatever code comes after the for loop. The number of loops that a for loop executes can also be set by counting down from a higher number to a lower number. To demonstrate this, add the following loop to the Project 2 sketch after the second for loop:



for (int b = 5 ; b > 1 ; b--)
{
digitalWrite(b, HIGH);
delay(d);
digitalWrite(b, LOW);
delay(d);
}

1 Like

Re: Free Arduino Tutorials by princejude(m): 4:22pm On Jan 17, 2015
Pulse-Width Modulation(PWM) – Varying led Brightness

Rather than just turning LEDs on and off rapidly using digitalWrite(), we can define the level of brightness of an LED by adjusting the amount of time between each LED’s on and off states using pulse-width modulation (PWM). PWM can be used to create the illusion of an LED being on at different levels of brightness by turning the LED on and off rapidly, at around 500 cycles per second. The brightness we perceive is determined by the amount of time the digital output pin is on versus the amount of time it is off—that is, every time the LED is lit or unlit. Because our eyes can’t see flickers faster than 50 cycles per second, the LED appears to have a constant brightness. The greater the duty cycle (the longer the pin is on compared to off in each cycle), the greater the perceived brightness of the LED connected to the digital output pin.

The greater the duty cycle (the longer the pin is on compared to off in each cycle), the greater the perceived brightness of the LED connected to the digital output pin.


Figure 3 shows various PWM duty cycles. The filled-in gray areas represent the amount of time that the light is on.
As you can see, the amount of time per cycle that the light is on increases with the duty cycle.

Only digital pins 3, 5, 6, 9, 10, and 11 on a regular Arduino board can be used for PWM. They are marked on the Arduino board with a tilde (~),
To create a PWM signal, we use the function analogWrite(x, y), where x is the digital pin and y is a value for the duty cycle, between 0 and 255, where 0 indicates a 0 percent duty cycle and 255 indicates 100 percent duty cycle.

To see figures click here because no time to upload http://www.jutronix.com/tutorials/arduino-tutorial/
Re: Free Arduino Tutorials by princejude(m): 4:27pm On Jan 17, 2015
Project 3: PWM Example

Now let’s try this with our circuit from Project 2. Enter the following sketch into the IDE and upload it to the Arduino:


// Project 3 - Demonstrating PWM

int d = 5;

void setup()
{
pinMode(3, OUTPUT); // LED control pin is 3, a PWM capable pin
}

void loop()
{
for (int a = 0 ; a < 256 ; a++)
{
analogWrite(3, a);
delay(d);
}

for (int a = 255 ; a >= 0 ; a--)
{
analogWrite(3, a);
delay(d);
}
delay(200);
}


The LED on digital pin 3 will exhibit a “breathing effect” as the duty cycle increases and decreases. In other words, the LED will turn on, increasing in brightness until fully lit, and then reverse. Experiment with the sketch and circuit. For example, make five LEDs breathe at once, or have them do so sequentially.
Re: Free Arduino Tutorials by princejude(m): 4:31pm On Jan 17, 2015
Project 4: Using a switch as digital input

Our goal in this project is to create a button that turns on an LED for half a second when pressed.

The Algorithm

Here is our algorithm:

1. Test to see if the button has been pressed.

2. If the button has been pressed, then turn on the LED for half a second,
and then turn it off.
3. If the button has not been pressed, then do nothing.
4. Repeat indefinitely.



The Hardware

Here’s what you’ll need to create this project:
• One push button
• One LED
• One 560 W resistor
• One 10 kW resistor
• One 100 nF capacitor
• Various connecting wires
• One breadboard
• Arduino and USB cable

The Schematic

First we create the circuit on the breadboard with the schematic shown in Figure 4. Notice how the 10 kW resistor is connected between GND and digital pin seven. We call this a pull-down resistor, because it pulls the voltage at the digital pin almost to zero. Furthermore, by adding a 100 nF capacitor across the 10 kW resistor, we create a simple debounce circuit to help filter out the switch bounce. When the button is pressed, the digital pin goes immediately to high. But when the button is released, digital pin seven is pulled down to GND via the 10 kW resistor, and the 100nF capacitor creates a small delay. This effectively covers up the bouncing pulses by slowing down the voltage falling to
GND, thereby eliminating most of the false readings due to floating voltage and erratic button behavior.

The Sketch

For the sketch, enter and upload the code below:


// Project 4 - Demonstrating a Digital Input

#define LED 12
#define BUTTON 7

void setup()
{
pinMode(LED, OUTPUT); // output for the LED
pinMode(BUTTON, INPUT); // input for the button
}

void loop()
{
if (digitalRead(BUTTON) == HIGH)
{
digitalWrite(LED, HIGH); // turn on the LED
delay(500); // wait for 0.5 seconds
digitalWrite(LED, LOW); // turn off the LED
}
}
Re: Free Arduino Tutorials by lordraiden(m): 10:34am On Jan 19, 2015
can anyone pls teach me microchip programming language
Re: Free Arduino Tutorials by princejude(m): 7:19pm On Jan 19, 2015
lordraiden:
can anyone pls teach me microchip programming language

Which of the microcontroller and which language ?
Re: Free Arduino Tutorials by lordraiden(m): 7:45am On Jan 20, 2015
princejude:

Which of the microcontroller and which language ?
pic controllers and c programming language
Re: Free Arduino Tutorials by princejude(m): 1:41pm On Jan 20, 2015
lordraiden:
pic controllers and c programming language

Check this thread https://www.nairaland.com/1214892/microcontrollers

1 Like

Re: Free Arduino Tutorials by lordraiden(m): 2:41pm On Jan 20, 2015
princejude:


Check this thread https://www.nairaland.com/1214892/microcontrollers
tnx.are u a programmer

modified:
no need for ansa hv seen for my self

cn i add u up on whatsapp
Re: Free Arduino Tutorials by princejude(m): 7:20pm On Jan 20, 2015
lordraiden:
tnx.are u a programmer

modified:
no need for ansa hv seen for my self

cn i add u up on whatsapp
Am not using whatsapp. I have uninstalled it from my phone. I don't know why.
Re: Free Arduino Tutorials by lordraiden(m): 9:11pm On Jan 20, 2015
princejude:
Am not using whatsapp. I have uninstalled it from my phone. I don't know why.
pls cn u reinstall,if u cnt actually say y u uninstalled it mayb it has no significant importance den,nw it has,cos i want to asking u some questn directly based on programming,i really need to learn it.tnx hope u do so
Re: Free Arduino Tutorials by princejude(m): 5:56am On Jan 21, 2015
lordraiden:
pls cn u reinstall,if u cnt actually say y u uninstalled it mayb it has no significant importance den,nw it has,cos i want to asking u some questn directly based on programming,i really need to learn it.tnx hope u do so
ok I will reinstall but would prefer if you ask your question here so that others will learn
Re: Free Arduino Tutorials by lordraiden(m): 9:26am On Jan 21, 2015
princejude:

ok I will reinstall but would prefer if you ask your question here so that others will learn
k,tnx bt smtimez i will need quicker response dats y i was asking for ur whatsapp and d thread u shared for mi is a little bit old,cnt really comment there,plus d place is full of gurus d codes are more like chinese to mi.lol
Re: Free Arduino Tutorials by lordraiden(m): 2:51pm On Jan 22, 2015
princejude:

sir am still waiting for d numba pls
Re: Free Arduino Tutorials by princejude(m): 4:55pm On Apr 24, 2015
Latest Arrival 30% discount:

ADXL335 ACCELEROMETER
ARDUINO UNO mega328 pdip
ARDUINO UNO mega328 smd
HC-SR04 ULTRASONIC
L298N MOTOR DRIVER
MQ-2 GAS SENSOR
LM3940 IT-3.3V Regulator
BC547
BC557
PIC18F2550-PDIP
DHT11
HC-SR501 PIR MOTION SENSOR
RELAY MODULE
U-BLOX GPS MODULE
SIM900 GSM
1uF/50V
10uF/50V
100uF/50V
22pF
Flame Sensor
SOIL MOISTURE SENSOR HYGROMETER
TK103 CAR TRACKER
CP2102 USB TO TTL
502 5K Blue trimmer Adjust Resistor
BUZZER BLACK
ARDUINO JUMPER WIRE
6X1 CABLE with female header FOR PICKIT3
ENC28J60/SD CARD MODULE
8p dupont 2.54mm pitch cable with female
4p dupont 2.54mm pitch cable with female
2p dupont 2.54mm pitch cable with female
28 pin IC Socket
40 pin IC Socket
2.54MM RIBBON CABLE (5meters)

http://www.jutronix.com/new-arrivals/

1 Like

Re: Free Arduino Tutorials by AAinEqGuinea: 7:03am On Apr 25, 2015
Got two Arduinos, breadboard, and other micros fired up.

Keep the thread alive. cool

(1) (2) (3) (Reply)

Python Programmers Lets Meet Here!!! / Humour: Does This Realy Say's Truth Abt Programmers / Should A Programmer Marry A Programmer?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 86
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.