Alex Glow
Published

SODAQ Mbili Quick Start Guide

Fade an LED by twisting a dial. A minimal Arduino sketch + Seeed Grove modules get you up and running fast.

BeginnerProtip30 minutes574
SODAQ Mbili Quick Start Guide

Things used in this project

Hardware components

SODAQ Mbili
×1
Grove starter kit plus for Intel Edison
Seeed Grove starter kit plus for Intel Edison
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Web Editor
Arduino Web Editor

Story

Read more

Code

PotFader.ino

C/C++
/*
  Brutally kludged together from:
  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
  http://www.arduino.cc/en/Tutorial/Fading
  ...by Alex Glow for Hackster.io
*/

int ledPin = 4;    // LED connected to digital pin 4

void setup() {
  Serial.begin(9600);
}

void loop() {
  int fadeValue = analogRead(0);
  Serial.println(fadeValue);
  fadeValue = map(fadeValue, 0, 1023, 0, 255); // scale potentiometer reading to the LED's brightness range
  analogWrite(ledPin, fadeValue);
  delay(1);  // delay in between reads for stability
}

Credits

Alex Glow

Alex Glow

108 projects • 1120 followers
The Hackster team's resident Hardware Nerd. I like robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments

Add projectSign up / Login