Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active August 29, 2015 14:24
Show Gist options
  • Save stonehippo/73c9a4cd84f575a3e128 to your computer and use it in GitHub Desktop.
Save stonehippo/73c9a4cd84f575a3e128 to your computer and use it in GitHub Desktop.
Spark: Intro to Arduino
void setup() {
// This code is run once, each time the Arduino is powered on or reset
}
void loop() {
// This code is run repeatedly, as fast as the Arduino can run it
}
const int LED = 13;
const int BUTTON = 5; // use a momentary switch
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTON) == LOW) {
digitalWrite(LED, HIGH);
delay(250);
digitalWrite(LED, LOW);
delay(250);
}
}
// For this example, I'm using an FSR, but just about any simple analog sensor would work
const int SENSOR_PIN = A0;
int fsrReading = 0;
void setup() {
Serial.begin(9600); // fire up Serial so we can output values to the console
}
void loop() {
// Read the state of the analog pin, and get back a value in the range 0-1024
fsrReading = analogRead(SENSOR_PIN);
// Display the value we read on the Serial console
Serial.print("The current reading from the FSR is: ");
Serial.println(fsrReading);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment