Posts

Controlling a motor with a transistor

Image
What are transistors How do transistors work. For NPN transistors Saturation.  Current flows from Collector to Emitter.  Occurs when the voltage of the base passes a threshold. Cut off.  No current flows from collector to emitter Caused when the voltage of the base is below another threshold (usually 0.6V) Active.  Output voltage is proportional to base voltage.  (Difficult to use with the Pi as we don't control the output voltage with the Pi).  Caused when the voltage is between 1 and 2 thresholds. Reverse Active (unusual state where the current goes from the emitter to the collector.) Youtube video Youtube video Difference between NPN and PNP Using the Pi to control the motor using PWM Flyback diodes (Protection) Youtube Video Trans BC548 Zerner 10V will do

Making a buzzer sound.

Image
  import RPi.GPIO as GPIO import time buzzer_pin = 18 GPIO.setmode (GPIO.BCM) GPIO.setup (buzzer_pin, GPIO.OUT) def buzz (pitch, duration):     print ("Pitch is " + str(pitch) + "Hz")     print ("Duration is " + str(duration) + "seconds")     period = 1.0 / pitch     #Trace period = 1/1000 = 0.001     print ("Period is " + str(period) + "seconds")     delay = period / 2     #Trace delay = 0.001/2 = 0.0005     cycles = int (duration * pitch)     #Trace cycles = 4 * 1000 = 4000     print ("Cycles are " + str(cycles))     #range function returns a sequence of numbers     for i in range (cycles):         GPIO.output (buzzer_pin, True)         time.sleep(delay)         GPIO.output (buzzer_pin, False)         time.sleep(delay) try:     while True:         #Chang...

Pulse Width Modulation

 How it works Link to Sparkfun tutorial Code... import RPi.GPIO as GPIO import time #BCM refers to how the pins are refered to. #See here for reference #https://raspberrypi.stackexchange.com/ #questions/12966/ #what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering GPIO.setmode(GPIO.BCM) led_pin = 18 GPIO.setup(led_pin, GPIO.OUT) #This is setting the pulse frequency to 500Hz #Actually this is kind of true but the accuracy falls off #as the frequency rises. pwm_led = GPIO.PWM(led_pin, 500) #This means that the led gets started at 100% of the cycle pwm_led.start(100) try: while (True): #change to raw_input if using python 2 duty_s = input("Enter Brightness (0 to 100 or x to exit):") if duty_s == 'x': break #The following checks the input is a number #and the number is between 0 - 100 #if the user inputs an x exit try: duty = int (duty_s) isNumber = True ...

List of equipment Required

 Found at this link

H Bridge L293D for Controlling Electric motor

Image
 https://www.jaycar.com.au/l293d-dual-full-bridge-motor-driver-ic/p/ZK8880?gclid=Cj0KCQiA99ybBhD9ARIsALvZavXfvItmsfMmLZ8WsUfCOEAjqs1a3MX0r2dXJQ2iNfKduH8h_BOqFU4aAq7SEALw_wcB Data Sheet https://www.jaycar.com.au/medias/sys_master/images/images/9725482270750/ZK8880-dataSheetMain.pdf Pin1 18 Pin2 23 Pin3 Motor Lead (1) Pin4 GND Pi Pin6 Motor Lead (2) Pin7 24 Pin8 Power Supply + Pin16 5V Pi Pin 13 Power Supply -

Using the MCP3008 Analog to Digital chip

Image
  With Pictures Order from RS  Data sheet from RS Connections Voltage Divider (For use with sensor based resistors)

Pull Down and Pull Up Resistors

Image
  From https://youtu.be/Bqk6M_XdIC0