Skip to content

Instantly share code, notes, and snippets.

/*
A Processing sketch takes an analog input from the serial bus and uses it to scale a color a rectangle.
*/
import processing.serial.*;
// this selects the port number for your computer. If the code has trouble, try
// changing this value to a number between 0 and 9
int portNum = 3; // selects the port number
@scottswaaley
scottswaaley / Analog_Read_Serial_Write.ino
Last active March 22, 2016 16:21
A great intro sketch for writing analog sensor data to the serial bus.
/*
An Arduino sketch that reads an analog input from pin A0 and writes a '0' or '1' to the serial bus.
*/
void setup() {
Serial.begin(9600);
Serial.println("SERIAL READY");
}
/*
A Processing sketch takes a digital input from the serial bus and uses it to scale a color a rectangle.
*/
import processing.serial.*;
// this selects the port number for your computer. If the code has trouble, try
// changing this value to a number between 0 and 9
int portNum = 3; // selects the port number
/*
An Arduino sketch that reads a digital input from pin A0 and writes a '0' or '1' to the serial bus.
*/
void setup() {
Serial.begin(9600);
Serial.println("SERIAL READY");
/*
This is a comment block.
Anything between the start and end symbols is ignored by the compiler.
*/
// This is an in-line comment. Anything after the start symbol is ignored by the compiler (as long as it is on the same line)
int myNum; // declares an integer named myNum
myNum= 13; // sets the integer named myNum equal to 13
int myNum= 13; // simultaneously declares an integer named myNum and sets it equal to 13
float myDec; // declares a decimal named myDec
myDec= 13.001; // sets the decimal named myDecequal to 13.001
float myDec= 13; // simultaneously declares a decimal named myDecand sets it equal to 13
char theChar; // declares a character named theChar
theChar = ‘a’; // sets the character named theChar equal to the letter ‘a’. Notice that the character is surrounded my apostrophes.
int age = /* some user input*/;
if( condition_1 ) {
// if condition_1 is true, then do some stuff here and skip all the else clauses
} else if( condition_2 ) {
// if condition_1 is false but condition_2 is true, then do some stuff here then skip the last else clause
} else {
// if condition_1 and condition_2 are false, then do stuff here
}
int i = 0;
while(i<10) {
Serial.print("I am on # ");
Serial.println(i);
i = i+1;
}
if( age > 55) {
Serial.println("You are a Senior Citizen");
}
if( age >= 13 && age <= 19) {
Serial.println("You are a teenager");
}
if( age < 13 || age > 65 ) {
Serial.println("Your either too old or too young to be playing with an Arduino");
function doGet() {
var app = UiApp.createApplication();
var label = app.createLabel("Hello World");
app.add(label);
return app;
}