When a pin is HIGH it can power an LED (or other electronics). I adapted it to light up the LED when my web server is unreachable using urllib2.Įxplanation: Arduino has a set of General Purpose Input/Output (GPIO) pins that have two settings, HIGH and LOW (1, and 0). The Python code can be heavily modified and adapted to fit your needs. Input += (char) Serial.read() // Read in one char at a timeĭelay(5) // Delay for 5 ms so the next char has time to be received PinMode(led, OUTPUT) // Set pin 13 as digital out # If on Windows or "No such file '/dev/ttyACM0'" change (If this all sounds foreign to you, please scroll down to bottom of the post for explanation.) The following Python script sends "on" or "off" through the Serial Monitor, which is then read by the Arduino to control an LED on PIN 13. Using Python and it's pySerial module we can control Arduino's serial port, and thus it's Serial Monitor (think I/O). Mainly, it has no native internet connectivity.Įnter the Python (and a computer like a Raspberry Pi) That doesn't mean it's weak either.Īrduino is amazing by itself but the entry level board, the Arduino Uno (pictured above, ~35$) has some limitations. Arduino is an electronics platforming tool that is as fun as it is easy to get into.
0 Comments
Leave a Reply. |