This is a Raspberry Pi experimental tray kit for raspberry beginners or Arduino beginners.
It contains a long breadboard and a breadboard power supply that provides 3.3v and 5v power to the breadboard power rails.
It is easy to deploy electronic components and the Raspberry Pi or Arduino development board can be fixed on the tray.
It is convenient to carry out and can protect the device well, prevent short circuit and so on.
It can also prevent the jump wire from loosening during the movement.
Fit for circuit experiments with Raspberry Pi and Arduino Uno/Mega 2560.
Features
Easy to assemble
ABS Material with screw holes
Long breadboard
Starter kits for the electronic experiments
Compatibles with Raspberry Pi and Arduino Uno/mega 2560
4. Connect LED and 220Ω Resister to breadboard and connect LED to Raspberry Pi's GPIO on Pin number 12 as following picture:
Blinking_circuit.jpg
| Blinking.jpg |
5. Create a file with code as following:
Programming in Language C:
Create a file named led.c and paste following code:
#include <stdio.h>
#include <wiringPi.h>
//define the led macro value. 1 means wiringPi name style, you should connect led positive pin to physical pin 12.
int LED = 1;
// main function
int main(void)
{
// initialized environment
// infinity loops
wiringPiSetup();
pinMode(LED, OUTPUT);
//Loops
for(;;)
{
digitalWrite(LED,HIGH); //Turn on led
delay(20);
digitalWrite(LED,LOW); //Turn off led
delay(20);
}
return 0;
}
Compile and run it:
gcc -o led -lwiringPi led.c
./led
Programming in Python:
1.Install RPi.GPIO:
pip3 install RPi.GPIO
2. Create a file named blink_led.py and paste following code:
#!/usr/bin/env python3
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
LED = 18 # Define led pin's name (BCM naming style)
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BCM) # Use physical pin numbering
GPIO.setup(LED, GPIO.OUT, initial=GPIO.LOW) # Set pin 18 to be an output pin and set initial value to low (off)
while True: # Run forever
GPIO.output(LED, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(LED, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second
// header files
#include <stdio.h>
#include <wiringPi.h>
int LED[3]= {0,1,2}; // define an array to store leds pin, 0 - blue led, 1 - green led, 2 - red led.
int x = 200; // interval for the delay.
int main(void)
{
wiringPiSetup(); //initialized wiringPi.
for(int i=0; i<3; i++)
{
pinMode(LED[i], OUTPUT); // set direction of the LED pin to output.
digitalWrite(LED[i], HIGH); // turn off all leds.
}
for(;;)
{
for(int i=0; i<3; i++)
{
if(i==0)
{
digitalWrite(LED[i],LOW); //turn on blue led
digitalWrite(LED[i+1],HIGH); //turn off green led
digitalWrite(LED[i+2],HIGH); //turn off red led
delay(x);
}
if(i==1)
{
digitalWrite(LED[i],LOW); //turn on green led
digitalWrite(LED[i-1],HIGH); //turn off blue led
digitalWrite(LED[i+1],HIGH); //turn off red led
delay(x);
}
if(i==2)
{
digitalWrite(LED[i],LOW); //turn on red led
digitalWrite(LED[i-1],HIGH); //turn off green led
digitalWrite(LED[i-2],HIGH); //turn off blue led
delay(x);
}
}
}
return 0;
}
Compile the code with gcc tool and run:
gcc -o rgbled -lwiringPi rgbled.c
./rgbled
Lesson 3 Buzzer
Build circuit
\* Connect the long pin of the buzzer to 3V3 pin on Raspberry Pi and short pin to GPIO.2
Morse code device will help childs to learn morse code:
* Build circuit
Morsecode.jpg
| Morsecodemech.jpg |
Write the code
#include <stdio.h>
#include <wiringPi.h>
#define LED 1
#define BUTTON 0
int x = 200;
int main(void)
{
wiringPiSetup(); //initialized
pinMode(LED, OUTPUT); // set direction of the led pin.
digitalWrite(LED, LOW); // turn off led
pinMode(BUTTON, INPUT); // set direction of button pin as input pin
for(;;)
{
if(digitalRead(BUTTON) == 0) // read Button's status
{
delay(15); // bounce time
if(digitalRead(BUTTON) == 0)
{
digitalWrite(LED,LOW); // led pin's status will turn on the buzzer and led.
}
else
{
digitalWrite(LED,HIGH); // turn off.
}
}
}
return 0;
}