two_way_serial_communication_arduino_and_processing_test_and _implementation

After I connected successfully the two pings on the breadboard and made the Arduino read their input, I had to connect it to Processing. Last year we used StandardFirmata to link Processing and Arduino and I already used it for our first demo, but now I could not rely on the firmata code anymore and I had to now make my Arduino sketch send the output it receives to Processing and there incorporate it into my Minim sketch that I created for the demo.

I researched and read though the examples from last year and first made a small test with a potmeter and an LED, when you turn the potmeter the light is dimmed. Then after I realised how the Serial port communication works it was a matter of adding a line in the setup() function to start the Serial connnection at a baud rate of 9600 and use the COM3 of my laptop to send an array of two numbers indicating what the ultrasonic sensors “see”. Then in Processing I read the array, trim it, read the individual numbers and assign to a variable ultrasonic1 and ultrasonic 2. Then if anything gets in a range smaller then 50, music will start playing and in any other case it will stop and rewind back to beginning.

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started