K-0502: Difference between revisions
Line 153: | Line 153: | ||
|[[File:RGBDESC.jpg|right|500px]] | |[[File:RGBDESC.jpg|right|500px]] | ||
|} | |} | ||
* Connection Details | |||
* Demo status | * Demo status | ||
{| | {| |
Revision as of 13:45, 1 November 2019
ABS Holder Kit for RPi & Arduino
Description
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
- Breadboard power supply (Offer 3.3V and 5V)
- Two Colors: Blue & Green
Gallery
Package Includes
- 1 x ABS Holder Kit For RPi & Arduino(experimental tray kit)
- 1 x Long breadboard
- 1 x Breadboard power supply(6.5-12V DC Input,5V/3.3V Output)
- 5 x Red LED
- 5 x Blue LED
- 5 x White LED
- 5 x Yellow LED
- 5 x Green LED
- 2 x RGB LED
- 2 x Button
- 1 x Buzzer
- 10 x 1KΩ Resister
- 2 x Acrylic washer
- 40 x Male-to-Female jump wire
- 40 x Male-to-Male jump wire
- 15 x Screw
- 1 x Anti-slipper pad
- 1 x Screw driver
Applications
Documentations
Lesson 1 Blinking LED
- Steps:
- 1. Download the latest image file(Raspbian) from: https://www.raspberrypi.org/downloads/
- 2. Unzip it and flash it to TF card by using Etcher tool or win32_diskimager tool.
- 3. Remove old version of wiringPi software and download and install the latest wiringPi software:
sudo apt -y purge wiringpi hash -r cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio readall gpio -v
- 4. Connect LED and 220Ω Resister to breadboard and connect LED to Raspberry Pi's GPIO on Pin number 12 as following picture:
- 5. Create a file with code as following:
- Programming in Language C:
- 5. Create a file with code as following:
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
3.Run the code:
python3 blink_led.py
Leson 2 RGB LED Shifting
- Component and pin definitions
- Connection Details
- Demo status
- Demo code
// header files #include <stdio.h> #include <wiringPi.h> // define an array called LED and have 3 elements, 1 means GPIO.1, 2 means GPIO.2, 3 means GPIO.3 int LED[3]= {1,2,3}; // define the interval time in ms, 200 means 200ms. int x = 200; int main(void) { wiringPiSetup(); //initialized for(int i=0; i<3; i++) // setup the pin's direction and set low level for each pin. { pinMode(LED[i], OUTPUT); digitalWrite(LED[i], LOW); } for(;;) // loop { for(int i=0; i<3; i++) { digitalWrite(LED[i],HIGH); //turn on led digitalWrite(LED[i+1],HIGH); // turn on second led delay(x); digitalWrite(LED[i],LOW); //turn off led delay(x); } } return 0; }
- Compile the code with gcc tool and run:
gcc -o rgbled -lwiringPi rgbled.c ./rgbled
Lesson 2 Buzzer experiment on RPi 4B
- Build circuit
- Connect the long pin of the buzzer to 3V3 pin on Raspberry Pi and short pin to GPIO.2
- Demo code
#include <stdio.h> #include <wiringPi.h> #define buzzer 0 // gpio.0 Equal BCM Pin 17 int interval = 0; int main(void) { wiringPiSetup(); pinMode(buzzer, OUTPUT); digitalWrite(buzzer, LOW); for(;;) { for(interval=0; interval<=50; interval+=2) { digitalWrite(buzzer,HIGH); delay(interval); digitalWrite(buzzer,LOW); delay(interval); } for(interval=50; interval>=0; interval-=2) { digitalWrite(buzzer,HIGH); delay(interval); digitalWrite(buzzer,LOW); delay(interval); } } return 0; }
- Compile it and run:
gcc -o buzzer -lwiringPi buzzer.c ./buzzer