Group:
Michael Pauls (mepauls2)
Soham Karanjikar (sohammk2)
Joo Yong Chung (jdchung2)
ECE 110/120 LED Speedometer
Introduction
The purpose of this project is to build a LED lighting device to indicate the speed of any moving device through different colors. The three colors we are going to be using are red, green, and yellow. We chose this color as these colors are familiar to everyone in what they mean. Red is stop, yellow is slow, and green is moderate/fast. Such lighting device can be useful for pedestrians at night, as they would be able to recognize the vehicle at plain dark through LED lights and also get a sense of how fast the vehicle is moving. If customized, this can prevent many accidents that happen at night between pedestrians and moving devices such as bikes and longboards. Also, if this product were to be sold, it will be very popular because of its low cost as it is very simple to build this product.
Wheel: We will attach a magnet to the wheel. Whenever the wheel spins, the hall effect sensor will detect the magnet to calculate the revolution per minute.
Arduino: We will use arduino to analyze the information the hall effect sensor sends (which is essentially revolution per minute of the wheel). We will first convert this into meters per second through simple coding. After such conversion, by using the Arduino coding, we made LED strip to light up red when it has 0 rpm or m/s (which is essentially a default state), yellow when it’s going slow/moderate state (.25 m/s to 1m/s), and Green if it’s anything beyond 1m/s to indicate that it’s going fast.
Protoboard: We will be using NAND gate logic to light up an LED bulb in the protoboard when the color RED is on. When it’s in other colors, such as green and yellow, we will make the bulb to not light up.
LED Strips: It will be used to light up 3 colors which are red, yellow, and green.
Logic Gate: Make the LED bulb turn green whenever the strips turn to Green.
Arduino Code
int halfrevolutions;
float rpm;
float ms;
float time1;
unsigned long oldtime;
#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
#define int logic;
#define int logicG;
void setup()
{
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, 13>(leds, NUM_LEDS);
attachInterrupt(0, magnet_detect, RISING);
halfrevolutions = 0;
rpm = 0;
oldtime = 0;
time1 = 0;
logic = 4;
logicG = 6;
}
void loop()//Measure RPM
{
if ( halfrevolutions < 10 && (millis() - oldtime) > 3000) {
for (int i = 0; i < 60; i++) {
leds[i] = CRGB::Red; FastLED.show();
}
//Serial.println("RED");
}
else if (halfrevolutions >= 10) {
rpm = 30*1000/(millis() - oldtime)*halfrevolutions;
Serial.println(millis()-oldtime,DEC);
oldtime = millis();
halfrevolutions = 0;
ms = rpm * 0.21362830044/60;
Serial.print(rpm ,DEC);
Serial.println(" rpm");
Serial.print(ms,DEC);
Serial.println(" m/s");
if (ms > 1){
for (int i = 0; i < 60; i++) {
leds[i] = CRGB::Green; FastLED.show();
}
digitalWrite(logic, HIGH);
digitalWrite(logicG, HIGH);
}
else if (ms > .25) {
for (int i = 0; i < 60; i++) {
leds[i] = CRGB(255,100,0); FastLED.show();
}
}
else {
for (int i = 0; i < 60; i++) {
leds[i] = CRGB::Red; FastLED.show();
}
}
}
}
void magnet_detect()
{
halfrevolutions++;
halfrevolutions++;
Serial.println("detect");
}
Results
The result was somewhat successful. By using the hall effect sensor to detect the revolution per minute of the wheel, we were able to convert rpm to meters per second through arduino. After such conversion, we programmed the arduino to produce Red when the speed is 0 or it’s in any default state, yellow when it’s between .25m/s to 1m/s, and green if the speed is anything beyond that. However, we weren’t able to make the LED lights to turn into just three colors consistently, as many sects of the LED lights often showed up with random colors often.
Problems and Challenges
One problem for this project was definitely the coding. Even though we had some knowledge in coding with arduino, what our project was doing was relatively new things that we haven’t learned yet. We also had a lot of trouble finding the ports whenever we ran the program, in which we realized that it wasn’t our problem but rather there was an error with the computer. Another problem we faced was coding itself. One mistake led to hours of decoding the bug, in which we spent most of our time working on doing. We sat in front of the computers for hours and hours just to realize the fact that we didn’t put a parenthesis at the end.
However, I would say the major problem for this project was definitely LED light coming on the week that the project was due. Due to this, we had to struggle to make LED light to work in such a short given time. Although the light strip does work, it doesn’t work consistently as we origninally thought, as several different colors show up often when we try to make the color be either all red, yellow, or green.
Future Plans
Our future plan for this project is to make the LED Strip to compute more advanced functions. Such functions that we want to accomplish is to make the LED strip show more colors to make it more colorful and visually pleasing. Also, we can create functions that make the LED show different patterns of lights. To achieve this however, is beyond our scope, and we firmly believe that this can be achieved when we learn more about coding and how arduino work.
References
Cdn-shop.adafruit.com. (2017). WS2812B Intelligent Control LED Integrated light source. [online] Available at: https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
GitHub. (2017). FastLED/FastLED. [online] Available at: https://github.com/FastLED/FastLED
Instructables.com. (2017). Control Ikea Dioder LED Strip With Arduino + 16X PWM LED Fader Board. [online] Available at: http://www.instructables.com/id/Control-Ikea-Dioder-LED-Strip-with-Arduino-16X-P/
Martson, R. (2017). Understanding Digital Buffer, Gate, and Logic IC Circuits - Part 3. [online] Nuts and
Volts Magazine. Available at: http://www.nutsvolts.com/magazine/article/understanding_digital_buffer_gate_and_logic_ic_circuits_part_3