Nicolasrs11
Published © GPL3+

NeoPixels Bicycle Project

This project was made with the intention to create a reflexion around the effort of cyclists, made with a Hall effect sensor.

BeginnerProtip499
NeoPixels Bicycle Project

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Hall Effect Sensor
Hall Effect Sensor
×1
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Sketch

The temperature sensor is used as a representation of the Hall effect sensor.

Code

Hall effect_neopixels

Arduino
Most of the comments on the code are written in Spanish.
//Libreria Adafruit

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

//Pin al que se encuentra conectado (analogo)

#define PIN        A1

//Nmero de luces que se encuetran conectados

#define NUMERO_LUCES 64

/*Parmetros:
 * 1. Nmero de luces
 * 2. Pin eal que se encuentra conectado
 * 3. Codigo de luz al que se somete
 * 4.  
 *   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
 */                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Adafruit_NeoPixel pixels (NUMERO_LUCES, PIN, NEO_RGB + NEO_KHZ800);

const int hallPin = 9;     // hall effect sensor out pin
int hallState = 0;         // Initial hall sensor status

int i = -1;                //Contador para las luces
int contador = 0;          //Contador del sensor Hall
int limite = 160;          //Limite para que el contador se reinicie y encienda una luz

void setup() 
{

  Serial.begin(9600);
      
  pinMode(hallPin, INPUT); // The hall effect sensor pin as an input

  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
  #endif

  //Inicializacin del strip.
   
pixels.begin(); //Inicializa el Strip Object
pixels.show();  //Apaga las luces


}

void loop()
{

  hallState = digitalRead(hallPin); // reading the state of the hall effect sensor pin

  if (hallState == LOW)             // Registra +1 cada vez que se registra un paso de un imn.
  {     
    contador++;
  } 
    if (contador == limite)         //Enciende una luz cuando el contador llega a su limite
  {
      contador = 0;
      i++;
      for (int a = 0; a <= i && a < NUMERO_LUCES; a++)
        { 
          if (a >= 0 && a < 21)                //Modifica la luz del pixel nmero 0 a 20
          {         
            pixels.setPixelColor (a, pixels.Color(255,77,77));
          }
          if (a >= 21 && a < 42)               //Modifica la luz del pixel nmero 21 a 41
          {         
            pixels.setPixelColor (a, pixels.Color(0,255,255));
          }
          if (a >= 42 && a <= 64)              //Modifica la luz del pixel nmero 42 a 64
          {         
            pixels.setPixelColor (a, pixels.Color(0,255,255));
          }   
          pixels.show();
        }   
   }
   Serial.println(hallState);                 //Imprime los resultados recibidos por el sensor
}

Credits

Nicolasrs11

Nicolasrs11

0 projects • 0 followers

Comments