• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

The Coding Couple

Pair programming is a lifetime commitment.

  • Home
  • Categories
    • Arduino
    • JavaScript
    • Python
    • Raspberry Pi
  • About Us
    • Privacy Policy
  • Contact

Creation Crate Month 1: An Arduino powered Mood Lamp

May 22, 2016 by Ashley

Tinkering with microcontrollers has been on my “to try” list for quite some time.  I recently stumbled upon Creation Crate.  Creation Crate is a monthly tech education subscription box.   Each month you receive a Arduino UNO R3 and parts to complete a project. The instruction book includes the source code for the project.  The source code is licensed under the GNU General Public License.  Each month the projects increase in difficulty.  I thought Creation Crate would be a wonderful way to get my feet with wet with Arduino and programming electronics.

I was on the fence about signing up for the subscription box because I was not sure what to expect.  I intend to write a blog post for each Creation Crate I receive in case there is a reader out there on the fence like I was.

The Project

The project for month one is creating a mood lamp! The mood lamp changes colors and only turns on when it’s dark.

An Arduino powered mood lamp

An Arduino powered mood lamp

What’s in the Box

Inside of month one’s box we have:

  • Arduino UNO R3
  • Breadboard
  • USB Cable
  • Chinese Paper Latern
  • U-shaped Jumper wires
  • Regular Jumper wires
  • 2.2k OHM Resistor
  • a blue, red and green LED
  • Light Dependent Resistor (LDR)
This month's contents

Month one’s contents

Building the Hardware

The setting up the hardware was pretty simple.  The instruction book includes nice illustrations for connecting the hardware together.

Adding the LEDs, resistor and light dependent resistor

Adding the LEDs, resistor and light dependent resistor

Connecting the jumper wires

Connecting the jumper wires

Connecting the Arduino

Connecting the Arduino

Powering it up

Powering it up

Programming

Source code for the project is included in the instruction book.  Typing the sketch file was pretty straight forward. I did make one significant error when I tried to upload the sketch on the Arduino:  I selected the wrong port in the Arduino IDE.  I was stuck on this error for more time than I care to admit. (Doh! Never again!)

// License: GNU General Public License
// Creation Crate: Month 1 - Mood Lamp
int pulseSpeed = 1;
int ldrPin = 0; // LDR (Light Dependent Resistor) in Analog 0
int redLed = 11;
int greenLed = 10;
int blueLed = 9;
int ambientLight; // light value in the room
int power = 150;
float RGB[3];
float CommonMathVariable = 180/PI;
void setup() {
// put your setup code here, to run once:
// tells the UNO R3 to send data out to the LEDs
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
// sets all the outputs to LOW (off)
digitalWrite(redLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
for(float x = 0; x < PI; x = x + -.00001) {
// red LED
RGB[0] = power * abs(sin(x * (CommonMathVariable)));
// green LED
RGB[1] = power * abs(sin((x + PI/3) * (CommonMathVariable)));
// blue LED
RGB[2] = power * abs(sin((x + (2 * PI) / 3) * (CommonMathVariable)));
ambientLight = analogRead(ldrPin);
if(ambientLight > 600) {
analogWrite(redLed, RGB[0]);
analogWrite(greenLed, RGB[1]);
analogWrite(blueLed, RGB[2]);
}
else {
digitalWrite(redLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, LOW);
}
// Calculate the delay for each color depending on color
// brightness; brighter LEDs will change colour slower
for(int i = 0; i < 3; i++) {
if(RGB[i] < 1) {
delay(20 * pulseSpeed);
}
else if (RGB[i] < 5) {
delay(10 * pulseSpeed);
}
else if (RGB[i] < 10) {
delay(2 * pulseSpeed);
}
else if (RGB[i] < 100) {
delay(1 * pulseSpeed);
}
else {}
}
delay(1);
}
}
view raw mood_lamp.ino hosted with ❤ by GitHub

Final Thoughts

Creation Crate Month 1: An Arduino powered mood lamp

Creation Crate Month 1: An Arduino powered mood lamp

This was my first experience programming an Arduino board and I loved it!  The instruction book leaves out a lot of beginner details like, “what’s a resistor” or explaining the parts that make up an Arduino board, but I think that’s okay.  When I finished the project I was finally motivated to sit down and start reading my Getting Started with Arduino book.

Related Posts

  • Creation Crate Month 4: An Arduino powered LED dice gameCreation Crate Month 4: An Arduino powered LED dice game
  • Creation Crate Month 2: An Arduino Powered Memory GameCreation Crate Month 2: An Arduino Powered Memory Game
  • Creation Crate Month 3: An Arduino Powered Distance DetectorCreation Crate Month 3: An Arduino Powered Distance Detector
  • AdaBox 005: Break for Pi | Adafruit Subscription BoxAdaBox 005: Break for Pi | Adafruit Subscription Box
  • Tinkering Around with Adafruit’s PyBadge LCTinkering Around with Adafruit’s PyBadge LC
  • I made a Sphere-O-Bot (An EggBot Mod)I made a Sphere-O-Bot (An EggBot Mod)

Filed Under: Arduino Tagged With: arduino, arduino uno, creation crate, led, mood lamp, sketch, steam, stem, subscription box

Previous Post: « Surviving the Hackathon: Angular Attack 2016
Next Post: Creation Crate Month 2: An Arduino Powered Memory Game »

Primary Sidebar

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Recent Posts

  • Pokémon Color Picker | A web app built with HTML/CSS + JavaScript
  • Pokéball Single DIV CSS Drawing | Tutorial
  • Error: [🍍]: “getActivePinia()” was called but there was no active Pinia
  • Trijam #261 Game Jam Diary: One Wrong Move
  • Using WSL on Corporate VPN

Recent Comments

  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley Grenon on Creation Crate Month 2: An Arduino Powered Memory Game
  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • kelly on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley on Creation Crate Month 3: An Arduino Powered Distance Detector

Follow us on Instagram!

This error message is only visible to WordPress admins

Error: No feed found.

Please go to the Instagram Feed settings page to create a feed.

Categories

  • Arduino
  • Conferences
  • Debugging
  • Game Jams
  • HTML and CSS
  • JavaScript
  • Programming Languages
  • Python
  • Raspberry Pi
  • Today I Learned

Archives

  • May 2024
  • April 2024
  • March 2024
  • May 2022
  • December 2021
  • May 2021
  • March 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • June 2019
  • April 2019
  • September 2017
  • April 2017
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • April 2015
  • January 2015

Tags

adafruit arduino brackets c# code smell codestock coding standards conventions creation crate debugging developer devspace electronics es6 es2015 game development game jam gotcha hackathon hoisting html html5 javascript led naming conventions nintendo phaser pluralsight pokemon programmer python raspberry pi retro retropie scope self improvement single div single div drawing subscription box TIL today I learned troubleshooting vue vuejs windbg

Footer

About Us

We are the Coding Couple.  Two people who met in college and decided they wanted to pair program for the rest of their ...

Read More »

Most Recent Posts

Pokémon Color Picker | A web app built with HTML/CSS + JavaScript

Pokéball Single DIV CSS Drawing | Tutorial

Error: [🍍]: “getActivePinia()” was called but there was no active Pinia

Trijam #261 Game Jam Diary: One Wrong Move

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Copyright Notice

© The Coding Couple, 2015 – 2023. Excerpts and links may be used, provided that full and clear credit is given to The Coding Couple with appropriate and specific direction to the original content.

Copyright © 2025 · Foodie Pro Theme by Shay Bocks · Built on the Genesis Framework · Powered by WordPress