15. Interface and Application Programming¶
Individual assignment: write an application that interfaces a user with an input &/or output device that you made
Basics¶
Goal: start by getting the Arduino Redboard to run an on/off Python program using a GUI; then mimicking the procedure with my ATTINY1614 board. Download using Homebrew:
- Tkinter
- Python3
Baby Spirals¶
With so many places for things to go wrong, it’s hard to apply Spiral workflow to this process; so I added a smaller spiral to my process which was making things work with existing boards. I keep getting ‘UPDI initialisation error’ with my board–so not sure what’s going on there; but the good news is that I got programs installed and working with the Redboard (thanks Spencer)
Video Storytelling¶
Python + GUI by me on Vimeo.
Finally! I got the GUI to work with my board:
Python + GUI on MY board (woot woot) by me on Vimeo.
Code¶
Arduino IDE: pySerial_Arduino
int outPin = 6;
int incomingByte;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(outPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0) {
incomingByte = Serial.read();
incomingByte = incomingByte - '0';
if (incomingByte == 1){
digitalWrite(outPin, HIGH);
}
else if (incomingByte == 2){
digitalWrite(outPin, LOW);
}
}
}