A teeny tiny computer
Raspbian
Based on Debian Linux
sudo apt-get install all-the-things
A water analogy
High or Low
On or Off
1 or 0
General Purpose Input Output
LEDs, Motors, LCDs, Valves
Meters, Sensors, Buttons
A Raspberry Pi works like a normal computer
An Arduino is a microcontroller platform
Microcontrollers have more direct access to hardware
#define LED_PIN 13
void setup(void)
{
pinMode(LED_PIN, OUTPUT);
}
void loop(void)
{
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}
A cheap card off ebay isn't reliable long term storage
$ ssh [email protected]
...
$ ssh [email protected]
...
$ ssh [email protected]
...
$ ssh [email protected]
...
Use hostapd to create private WiFi network
Gives easy control without requiring monitor
Useful travelling abroad
Observe voltage and current requirements
5V and 3.3V are commonly used in digital electronics
5V is not 3.3V
Resistors reduce current flow
A red LED has a voltage drop of 1.8V
Rasperry Pi pins use 3.3V
That leaves 1.5V for the resistor
Current rating of 20mA for LED
Ohms Law: V = IR
1.5V ÷ 0.02A = 75Ω resistor
USB, RS232, RS485, UART
:)
00111010 00101001
Internal clock required
Must agree baud rate and protocol prior
use PiPHP\GPIO\GPIO;
use PiPHP\GPIO\Pin\PinInterface;
// Create a GPIO object
$gpio = new GPIO();
// Retrieve pin 18 and configure it as an output pin
$pin = $gpio->getOutputPin(18);
// Set the value of the pin high (turn it on)
$pin->setValue(PinInterface::VALUE_HIGH);
use PiPHP\GPIO\GPIO;
use PiPHP\GPIO\Pin\InputPinInterface;
$gpio = new GPIO();
$pin = $gpio->getInputPin(18);
$pin->setEdge(InputPinInterface::EDGE_BOTH);
$interruptWatcher = $gpio->createWatcher();
$interruptWatcher->register($pin, function ($pin, $value) {
echo 'Pin ' . $pin->getNumber() . ' changed to: ' . $value . PHP_EOL;
return true;
});
while ($interruptWatcher->watch(5000));
Keep them as light as possible
Record the event
Exit
Any questions?
@AndrewCarterUK