As mentioned earlier, prior to this class, I had no experience with programming. After trying a few different environments, I have found that Arduino seems to be straightforward enough for me to understand, which is why I have grown accustomed to using that.
For the programming assignment, I found that using Processing , which is very similar to the Arduino IDE was a good fit for me.
#include
SoftwareSerial mySerial(0, 1);
void setup() {
pinMode(7, OUTPUT);
pinMode(1, OUTPUT);
mySerial.begin(9600);
mySerial.println("What is going on?");
}
void loop()
{
int val = digitalRead(8);
if (val) {
mySerial.println(1);
} else {
mySerial.println(0);
}
delay(100);
}
import processing.serial.*;
Serial myPort; // The serial port
int lf = 10; // Linefeed in ASCII
String myString = null;
PShape owl;
PShape squirrel;
void setup() {
// List all the available serial ports
println(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[2], 9600);
owl = loadShape("owl.svg");
squirrel = loadShape("squirrel.svg");
size(800, 800);
}
void draw() {
while (myPort.available() > 0) {
myString = myPort.readStringUntil(lf);
if (myString != null) {
myString = trim(myString);
println(myString);
if (myString.equals("1")) {
// println("owl");
background(255);
shape(owl, 300, 300);
} else {
// println(myString);
background(255);
shape(squirrel, 300, 300);}
}
}
}