Devashish Gupta
Published © MIT

Controlling LED Brightness Using Bolt and Arduino

Controlling the brightness of LED using API calls for Bolt.

IntermediateFull instructions provided1 hour7,344
Controlling LED Brightness Using Bolt and Arduino

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×6
Resistor 330 ohm
Resistor 330 ohm
×6
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Male/Male Jumper Wires
×7
USB-A to B Cable
USB-A to B Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

Led brightness control

Code

Led brightness control

Arduino
#include <BoltIoT-Arduino-Helper.h>

int pwm_pin[] = {3,5,6,9,10,11};

String switchOn(String *data) {
  int pin = data[0].toInt();
  int pwm = data[1].toInt();
  if ((pin < 1) || (pin > 6)) {
    return "pin number should be b/w 1 and 6";
  }
  pin--;
  analogWrite(pwm_pin[pin],pwm);
  return "Pin"+String(pin)+"was set to pwm value"+String(pwm);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(3,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);
  boltiot.begin(Serial);
  boltiot.setCommandString("ON",switchOn,2,' ');
}

void loop() {
  // put your main code here, to run repeatedly:
  boltiot.handleCommand();
}

Credits

Devashish Gupta

Devashish Gupta

10 projects • 72 followers
Electronics student at NIT, Rourkela

Comments