LilyPad Safety Scarf

Pages
Contributors: Feldi
Favorited Favorite 2

Software Installation

Arduino IDE

The LilyPad USB Plus is programmable via the Arduino IDE. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing Arduino IDE

March 26, 2013

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

LilyPad USB Plus and Board Add-On

If this is your first time working with the LilyPad ProtoSnap Plus, you will need to add the board through the boards manager to your program. Please visit the LilyPad ProtoSnap Plus hookup guide for detailed instructions on installing drivers and programming a LilyPad via the Arduino IDE.

Heads up! The correct selection in the boards manager is the LilyPad USB Plus. The LilyPad USB Arduino is an different version of this board and, if selected, will not upload correctly to the LilyPad USB Plus.

Arduino Program

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

We have provided the code for this project below. Copy and paste it into your Arduino IDE and then upload it to your board. Make sure you have the correct board selected in the boards manager as well as the port under the port drop down.

language:c
//Melissa Felderman for SparkFun Electronics 2017

//variable for sensor pin
int sensorPin = A2;

//variable for light value
int lightValue;

//variable for LEDPin
int LEDPin = 11; 

void setup()
{
    // Set sensorPin as an INPUT
    pinMode(sensorPin, INPUT);

    //set LEDPin as OUTPUT
    pinMode(LEDPin, OUTPUT);


void loop()
{

   // Get the current light level
    lightValue = analogRead(sensorPin);

    //if light level is low, turn LEDS on
    if(lightValue <= 15){
      digitalWrite(LEDPin, HIGH);

    }
    //if light is high, turn LEDs off
    else {
      digitalWrite(LEDPin, LOW); 
    }


}

programming