Table of Contents

Arduino Setup

Things you need:

For linux you can run the software from bash or make a script. It is good to do sudo so you have all permissions for ports

After running the program, you can make or upload scripts. then comile and load

This document

many examples in this document show examples of code. Unless in a code box, the examples will start with $ and follow some of hte principals in the linux page on this wiki.

Coding Notes

IDEA!!!!!: Can write examples of if then (etc) operations of what would hapen if, and so on in the comments.

Basic scripts:

Minimum for a script:

void setup() {                   
 }
void loop() {
 }

Basic Sytax

No Code
/*
 you can write notes that will not be part of the scripte with forward slash star
then star forward slash to end
*/

End of line

Pins:

Unless othersiwse stated, pins are just indicated by numbers such as this indicated pin 13 on the actual board:

Other:

Advanced Syntax

Cast

Cast is a way of converting one type of data, to another type,

float bright = sensorValue * (255.0 / 1023.0);
int bint; // a way to define an int name, but give no value
float bflo; // define float name, but give no value
bflo = bright; // sets what value the float is
bint = (int)bflo; // this is the cast directive 
analogWrite(led, bint); // for this example, it would cast the light as an int through a pwm pin and allow it to be an integer between 0-255

Script setup:

Before setup you can define things such as int

void setup

More:http://arduino.cc/en/Reference/Setup. “The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board. ”

Within the void setup brackets {}

Numbers and more

int
float
long

Before operators

const

unsigned

Modes

read

read analog

if else

if ([if formula])
{
 // then do this
}
else {
// then do this
}
else if ([if then formula)
{
// Then do this
}

Operators

Serial

Readouts

Glossery:

last code