Raspberry Pi Diaries
Jan 24, 2016
Last night, my Raspberry Pi Model B Rev 2 started acting erratically and then it decided to not even boot. I decided to rebuild the SD card and reinstall everything.
After flashing the SD card with the Raspian Jessie release, the PI booted up. I then proceeded to install everything I needed for the Raspberry PI bridge using my own instructions here.
I then installed the pigpio library.
Doing this on the Model B rev 2 (not to be confused with the Pi2) was a very slow process. To do everything took over 3 hours. I will be doing the same on a Pi2 in the future just to compare the differences in time to do a complete reinstall.
I installed the SD card into the Pi, it booted up and everything seemed right with the world again. I did a shutdown of the Pi to make sure not to corrupt the image, unplugged it and went to bed. This morning I powered up the Pi and it wouldn't boot, so I thought I would swap the SD card into a Pi 2 to see if it would boot, and it did - the image was not corrupted. I swapped it back to the B and no boot. So I have a flaky Raspberry Pi B rev 2. I will deal with this later, but will continue work on the Pi 2.
Tone and Tone Off have been implemented. I can't believe how easy it was to do this using pigpio - what a wonderful library. I used some of the "wave" methods. The only confusing part was figuring out how to populate the "pulse" class entries to create audio frequencies.
Here is some commented test code using pigpio waves:
import time # import the time library import pigpio # import the GPIO library pin = 18 # establish 2 pulse definitions to create a 1k hz tone # the first entry sets pin 18 high for a duration of 1000 microseconds # and the second entry set pin 18 low for a duration of 1000 microseconds tone_1k = [pigpio.pulse(1 << pin, 0, 1000), pigpio.pulse(0, 1 << pin, 1000)] # remember to execute "sudo pigpiod" on the Pi before executing #instantiate pigpio pi = pigpio.pi() # set the buzzer pin to output pi.set_mode(pin, pigpio.OUTPUT) # clear any previous wave descriptions pi.wave_clear() # create a wave descriptor pi.wave_add_generic(tone_1k) # 100 ms flashes # create the tone and save the id tone = pi.wave_create() # play tone continuously for one second pi.wave_send_repeat(tone) time.sleep(1) pi.wave_tx_stop() # stop waveform #clean up pi.wave_clear() # clear all waveforms
On to controlling servos next.