This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Problem</h1> | |
You want to connect external electronics to your Raspberry Pi but don’twant to accidentally damage or break it and How to Keeping Your Raspberry Pi Safe. | |
<h3>Solution</h3> | |
Obey these simple rules to reduce the risk of damaging your Raspberry Pi when using the GPIO connector | |
<ul> | |
<li>Do not put more than 3.3V on any GPIO pin being used as an input.</li> | |
<li>Do not draw more than 16mA per output and keep the total for all</li> | |
<li>outputs below 50mA in total for an older 26-pin Raspberry Pi, and below 100mA on a 40-pin Raspberry Pi.</li> | |
<li>When using LEDs, 3mA is enough to light a red LED reasonably brightly with a 470Ω series resistor.</li> | |
<li>Do not poke at the GPIO connector with a screwdriver or any metal object when the Pi is powered up.</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // Create | |
array for LED pins | |
int ledDelay = 65; // delay | |
between changes | |
int direction = 1; | |
int currentLED = 0; | |
unsigned long changeTime; | |
void setup() { | |
for (int x=0; x<10; x++) { // set all | |
pins to output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import RPi.GPIO as GPIO | |
import time | |
# Set GPIO numbering mode | |
GPIO.setmode(GPIO.BOARD) | |
# Set pin 11 as an output, and define as servo1 as PWM pin | |
GPIO.setup(32,GPIO.OUT) | |
servo1 = GPIO.PWM(32,50) # pin 11 for servo1, pulse 50Hz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import RPi.GPIO as GPIO | |
import time | |
# Set GPIO numbering mode | |
GPIO.setmode(GPIO.BOARD) | |
# Set pin 11 as an output, and set servo1 as pin 11 as PWM | |
GPIO.setup(22,GPIO.OUT) | |
servo1 = GPIO.PWM(22,50) # Note 11 is pin, 50 = 50Hz pulse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import RPi.GPIO as GPIO | |
import time | |
# Set GPIO numbering mode | |
GPIO.setmode(GPIO.BOARD) | |
# Set pin 11 as an output, and set servo1 as pin 11 as PWM | |
GPIO.setup(32,GPIO.OUT) | |
servo1 = GPIO.PWM(32,50) # Note 11 is pin, 50 = 50Hz pulse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int carRed = 12; // assign the car lights | |
int carYellow = 11; | |
int carGreen = 10; | |
int pedRed = 9; // assign the pedestrian lights | |
int pedGreen = 8; | |
int button = 2; // button pin | |
int crossTime = 5000; // time allowed to cross | |
unsigned long changeTime = 0; // time last pedestrian cycle | |
completed | |
void setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table attendance( | |
id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, | |
user_id INT UNSIGNED NOT NULL, | |
clock_in TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY ( id ) | |
); | |
create table users( | |
id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, | |
rfid_uid VARCHAR(255) NOT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import RPi.GPIO as GPIO | |
from mfrc522 import SimpleMFRC522 | |
import mysql.connector | |
db = mysql.connector.connect( | |
host="localhost", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import RPi.GPIO as GPIO | |
from mfrc522 import SimpleMFRC522 | |
import mysql.connector | |
db = mysql.connector.connect( | |
host="localhost", | |
user="username", | |
passwd="your_password", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import RPi.GPIO as GPIO | |
from mfrc522 import SimpleMFRC522 | |
import mysql.connector | |
db = mysql.connector.connect( | |
host="localhost", | |
user="username", | |
passwd="123", |
NewerOlder