Skip to content

Instantly share code, notes, and snippets.

@shawngrimes
shawngrimes / blink.ino
Created April 8, 2016 02:14
Simple Arduino Blink example demonstrating the use of a variable to store the pin number for the LED
@shawngrimes
shawngrimes / analog_fade.ino
Last active April 9, 2016 15:11
Basic Arduino sketch demonstrating analog output with a fade stepping LED.
int ledPin=9; //Store LED pin number in this variable
void setup() {
//No need for setup this time
pinMode(ledPin,OUTPUT); //Setup pin 9 for OUTPUT
}
void loop() {
analogWrite(ledPin,0); //Turn the LED on pin 9 off
delay(500); //Wait 500 milliseconds
@shawngrimes
shawngrimes / button.ino
Created April 8, 2016 02:29
Basic sketch demonstrating a digitalInput with a button
int ledPin=13; //Variable to store pin of LED
int buttonPin=3; //Variable to store pin of button
int buttonValue=0; //Variable to store last known value of button state
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT); //Setup LED pin for output
pinMode(buttonPin, INPUT); //Setup button pin for input
}
@shawngrimes
shawngrimes / analogRead.ino
Last active April 8, 2016 03:11
Basic sketch to demonstrate analog input.
int ledPin=9; //Variable to store pin of LED
int potentPin=A0; //Variable to store pin of potentiometer
int potentValue=0; //Variable to store last known value of potentiometer
int brightnessValue=0; //Variable to store LED brightness
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT); //Setup LED pin for output
}
int ledPin=9; //Variable to store pin of LED
int potentPin=A0; //Variable to store pin of potentiometer
int potentValue=0; //Variable to store last known value of potentiometer
int brightnessValue=0; //Variable to store LED brightness
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Setup serial console
pinMode(ledPin, OUTPUT); //Setup LED pin for output
}
#include <Process.h>
int ledPin=9; //Variable to store pin of LED
int potentPin=A0; //Variable to store pin of potentiometer
int potentValue=0; //Variable to store last known value of potentiometer
int brightnessValue=0; //Variable to store LED brightness
/////////////////
// Phant Stuff //
/////////////////
@shawngrimes
shawngrimes / sparkfun.ino
Last active April 9, 2016 05:15
data.sparkfun.com template
#include <Process.h> //Library for Sparkfun network connection
/////////////////////////////////
// Data.SparkFun.Com variables //
////////////////////////////////
// URL to phant server (only change if you're not using data.sparkfun
String phantURL = "http://data.sparkfun.com/input/";
// Public key (the one you see in the URL):
String publicKey = "xxxxxx";
// Private key, which only someone posting to the stream knows
#include <Process.h>
int ledPin=9; //Variable to store pin of LED
int potentPin=A0; //Variable to store pin of potentiometer
int potentValue=0; //Variable to store last known value of potentiometer
int brightnessValue=0; //Variable to store LED brightness
int moistPin=A1; //Variable to store pin of moisture sensor
int moistValue=0; //Variable to store moisture value
/////////////////
#include <YunClient.h>
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_Client.h>
int ledPin = 9;
/************************* Adafruit.io Setup *********************************/
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883
//This is a basic program to report the value of a photoresistor to the Adafruit.io service.
//These libraries are needed to talk to the Internet and the Adafruit service
#include <YunClient.h>
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_Client.h>
int photoPin=A0; //Variable to store pin of photoresistor
float photoValue=0; //Variable to store last known value of photoresistor