programming arduino

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bionary
 
Posts: 15
Joined: Wed Nov 28, 2012 7:18 pm

programming arduino

Post by bionary »

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

 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!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: programming arduino

Post by adafruit_support_bill »

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

/*
  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
bionary
 
Posts: 15
Joined: Wed Nov 28, 2012 7:18 pm

Re: programming arduino

Post by bionary »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”