Processing demo: Hotel room interface
This assessment shows the interaction between Arduino and Processing. In this demo, Processing is used to control the output of an LCD screen that is connected to an arduino uno. The 3 squares drawn in Processing “Food, Management, Security" each produce a different message on the LCD screen when clicked with the mouse.
Processing Code
import processing.serial.*;
Serial port;
void setup(){
port=new Serial(this,"COM10",9600);
size(600,200);
background(255);
}
void draw(){
fill(0,200,612);
rect(50,50,100,100,20);
rect(250,50,100,100,20);
rect(450,50,100,100,20);
textSize(16);
fill(255);
text("FOOD", 60, 105);
text("MANAGEMENT", 260, 105);
text("SECURITY", 475, 105);
Arduino Code
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int e = 0;
//int a = 0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop()
{
if(Serial.available());
e = Serial.read();
if (e == 97) //a in ASCII is 97
Results
Arduino components include:
LCD screen
1 bread board
220-ohm resistor
1 Arduino uno board
potentiometer