programming arduino

by bionary on Thu Feb 14, 2013 7:15 pm

After following all the instructions to get my arduino set up and going through a few tutorials, you know the led stuff, lcd screen, etc I wanted to take a step back and realize what was going on here.

It looks like arduino is taking commands from the language Processing? I played around with processing-js a year ago and it looks like the same IDE.

Is it Processing?

If so how come I can't output to the IDE's console window with a simple:
Code: Select all | TOGGLE FULL SIZE
 print("uhh yellow");


Is this the language guide I should be using:http://arduino.cc/en/Reference/HomePage ?

If I can't print out test statements to a console screen development is going to be a headache.

Any advice would greatly be appreciated, Thanks!
bionary
 
Posts: 15
Joined: Wed Nov 28, 2012 6:18 pm

Re: programming arduino

by adafruit_support_bill on Fri Feb 15, 2013 5:34 am

The Arduino IDE and programming language are derived from Processing. However, while Processing sketches execute on your computer, Arduino sketches are executing on the Arduino, so they can't write directly to the IDE console window.

What you can do, is write to the Arduino's serial port, and view this in the Serial Monitor window. To do this, you need to add a Serial.begin() to your setup. Then you can write to the serial port using "Serial.println() as in the example below:

Code: Select all | TOGGLE FULL SIZE
/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}
User avatar
adafruit_support_bill
 
Posts: 28061
Joined: Sat Feb 07, 2009 9:11 am

Re: programming arduino

by bionary on Fri Feb 15, 2013 5:58 pm

cool, that's good advice.
And if anyone else is looking into this- I got stuck looking for the printed output. (serial monitor window) I was looking below the sketch expecting to read output...
Simply go to tools>serial monitor and a separate window pops up. This youtube video actually shows it nicely:
http://www.youtube.com/watch?v=Y4iLB6SDiRg

Thanks again
bionary
 
Posts: 15
Joined: Wed Nov 28, 2012 6:18 pm