C.o6 Troubleshooting and Structure

Errors fixed

Untitled2

I took my code to get debugged by Spencer, and he identified my problems. Firstly, the condition inside the if statement (sensor = 1) needs to be (sensor ==1 ) since that indicates the difference between an assignment, telling the program that sensor now equals 1, and a comparison, asking the computer to check if sensor equals 1.

Secondly, the assignment of analogRead to the sensor variable needs to be repeated with each step, since new readings are being taken all of the time.

Thirdly, he noticed that i’ve been writing analogRead(A0); as this is what was used in the Arduino example. Instead, he recommended that i just write analogRead(0); since there is another use for A0 elsewhere in the program.

Now with the code fixed, the motor responds to the light sensor. When I hold my finger over the sensor, the motor turns in the opposite direction.

2017-03-08 18_19_02

The bigger structure

Processing must receive data from the QR code telling it which motor to activate, this data is then sent to the Arduino. Below is the code required to set up communication between the two programs

To assist, here is a diagram in plain english that shows a breakdown of the Arduino code (left) and how it interacts with the Processing code (right).

Bookscan

 

QR Codes

In the setup above, processing sends a value (1,2 or 3) to Arduino based on whether key 1, 2 or 3 is pressed. All that is left to do now is tack the QR code reader onto the end of this structure. Processing has a QR code reader library available, it was published by Daniel Shiffman. Here is a [link] to the library with some instructions on how to use to decoder.

The entire base sketch, including the decoder function, I obtained from [here].

[This] webpage also shows how to use ZXing to analyse QR Codes in realtime, should I need it.

Advertisements

Author: Pip Williamson

Pip // Animator & Motion Designer

1 thought on “C.o6 Troubleshooting and Structure”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s