I have begin trying to make a program that would be able to take input from the microcontroller and be able interface it so that it is able to take the information and use it in a program through my computer. As of recently I have been able to take input from the computer and send it to the mictocontroller and make i do things based on that through sending an ascii character to the device through a text based serial commuication. Though recently I have been working making an GUI for the computer so that I would be able to send the information through to the device and be able to read the information that is sent back. The program is written in Java script and is pretty straight forward to understand as well as use.
import processing.serial.*;
//gives Serial commands
Serial myPort;
//create Serial port
void setup()
{
String portName = Serial.list()[0];
myPort = new Serial(this,portName, 9600);
//Searches on 9600 bod for serial
}
void draw()
{
if(keyPressed)
{
if(key=='b' || key=='B')
{
fill(0);
//0 means black
myPort.write(98);
//98 is B lowercase
delay (5);
}
if(key=='g'||key=='G')
{
fill(0);
myPort.write(103);
delay(5);
}
}
else
{
fill (255);
//255 means White
}
rect(25,25,50,50);
}
No comments:
Post a Comment