Skip to content

Instantly share code, notes, and snippets.

@rahulbot
rahulbot / neopixel-simple.ino
Created February 16, 2023 18:29
Arduino Simple NeoPixel Example
#include <Adafruit_NeoPixel.h>
#define PIN_NEO_PIXEL 8 // Arduino pin that connects to NeoPixel
#define NUM_PIXELS 21 // The number of LEDs (pixels) on NeoPixel
#define DELAY_INTERVAL 100
Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800);
void setup() {
@rahulbot
rahulbot / neopixel-fastled-fire.ino
Created February 16, 2023 18:49
Arduino neopixel examples
#include "FastLED.h"
#define PIN_NEO_PIXEL 8 // Arduino pin that connects to NeoPixel
#define NUM_LEDS 21
CRGB leds[NUM_LEDS];
void setup() { FastLED.addLeds<NEOPIXEL, PIN_NEO_PIXEL>(leds, NUM_LEDS); }
void loop() {
/***********************************************************/
// Demo for the Serial MP3 Player Catalex (YX5300 chip)
// Hardware: Serial MP3 Player *1
// Board: Arduino UNO
// http://www.dx.com/p/uart-control-serial-mp3-music-player-module-for-arduino-avr-arm-pic-blue-silver-342439#.VfHyobPh5z0
//
// Uncomment SoftwareSerial for Arduino Uno or Nano.
#include <SoftwareSerial.h>
@rahulbot
rahulbot / motor qwiic.ino
Created February 20, 2024 19:26
Simple example of using motor driver QWIIC board from SparkFun
#include <Arduino.h>
#include <stdint.h>
#include "SCMD.h"
#include "SCMD_config.h" //Contains #defines for common SCMD register names and values
#include "Wire.h"
SCMD myMotorDriver; //This creates the main object of one motor driver and connected peripherals.
void setup()
{
#include <DFRobot_DF1201S.h>
#include <SoftwareSerial.h>
// Tell Arduino which pins are wired to MP3 player (remember RX on Arduino is TX on MP3 player)
SoftwareSerial DF1201SSerial(2, 3); //Arduino RX, Arduino TX
// object that will handle all comms to MP3 player
DFRobot_DF1201S DF1201S;
void setup(void){
@rahulbot
rahulbot / data-to-led.ino
Last active February 14, 2025 14:27
Arduino example of using a data array to change the brightness of an LED
#define LED_PIN 6 // PWM pin connected to the LED
int numbers[20] = {10, 90, 30, 80, 50, 60, 10, 80, 0,
100, 20, 40, 70, 20 , 50, 40, 90, 20, 10, 0};
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
@rahulbot
rahulbot / cityinfo.json
Created March 14, 2025 13:28
Sample data for an in-class project, generated with AI
[
{
"name": "Boston",
"photoUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSi1VjhimWStUSrm5wqFpEPLwSFXpwFiTfb3w&s",
"topSites": [ "Faniel Hall", "Boston Common", "Harvard University" ],
"description": "Boston is the capital of Massachusetts and known for its rich history and cultural heritage. Visitors love to explore its historic sites, museums, and vibrant neighborhoods."
},
{
"name": "Austin",
"photoUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJ6oRVJ7KZG9ZEaCtdkCNfniguZ5MfdB3D2A&s",
@rahulbot
rahulbot / MP3-debug.ino
Created April 1, 2025 13:28
Simple debug console for DFRobot DFPlayer Pro
#include <DFRobot_DF1201S.h>
#include <SoftwareSerial.h>
SoftwareSerial DF1201SSerial(2, 3); //RX TX
DFRobot_DF1201S DF1201S;
void setup(void){
Serial.begin(115200);
Serial.println("Initialize MP3 player");
@rahulbot
rahulbot / light-celebration-demo.ino
Created April 4, 2025 13:14
An example of fading an LED strip in the background so that the time-based animation doesn't interrupt the main flow of the program. This allows you to keep checkin motors, sensors, etc. while the animation runs.
/**
* An example of fading an LED strip in the background so that the time-based animation
* doesn't interrupt the main flow of the program. This allows you to keep checkin motors,
* sensors, etc. while the animation runs.
* @author Rahul Bhargava
*/
#include <Adafruit_NeoPixel.h>
#define DEBUG_LED_PIN 13
#define TRIGGER_PIN 7