Rotary Encoder RGB LED Controller

This project aims to teach you how to use the Rotary encoder to manipulate other components

COMPONENTS AND SUPPLIES

RGB Led

1

Rotary Encoder

1

Small Breadboard

1

InventrKits HERO

The HERO is a derivative of “Arduino UNO R3 Reference design” we just changed up a few things to make it our own. If you’re curious about what goes into our HERO board we published the open-source hardware files on our GitHub.

1

ABOUT THIS PROJECT

Use the rotary encoder to change the color of the RGB LED

CODE

				
					
				
			

SCHEMATICS

Rotary RGB

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *

#define CLK 2 #define DT 3 #define R 9 #define G 10 #define B 11 int currentLedValue = 0; int currentStateCLK; int lastStateCLK; String currentDir =””; int currentLedPin; void setup() { pinMode(CLK,INPUT); pinMode(DT,INPUT); pinMode(R,OUTPUT); pinMode(G,OUTPUT); pinMode(B,OUTPUT); Serial.begin(9600); currentLedPin = 9; lastStateCLK = digitalRead(CLK); } void loop() { currentStateCLK = digitalRead(CLK); if (currentStateCLK != lastStateCLK && currentStateCLK == 1){ if (digitalRead(DT) != currentStateCLK) { currentLedValue = currentLedValue – 5; currentDir =”CCW”; } else { currentLedValue = currentLedValue + 5; currentDir =”CW”; } if (currentLedValue > 255) { currentLedValue = 0; analogWrite (currentLedPin, currentLedValue); if (currentLedPin == 9) { currentLedPin = 10; } else if (currentLedPin == 10) { currentLedPin = 11; } else if (currentLedPin == 11) { currentLedPin = 9; } } if (currentLedValue < 0) { currentLedValue = 255; if (currentLedPin == 9) { currentLedPin = 11; } else if (currentLedPin == 11) { currentLedPin = 10; } else if (currentLedPin == 10) { currentLedPin = 9; } } Serial.print("Direction: "); Serial.print(currentDir); Serial.print(" | Led Value: "); Serial.println(currentLedValue); analogWrite (currentLedPin, currentLedValue); } lastStateCLK = currentStateCLK; }
PROJECT AUTHOR
Leave a comment
TEAM MEMBERS
Belrey

Everything

TABLE OF CONTENTS
Leave a comment
Share on whatsapp
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest
Share on email

SIMILAR PROJECTS YOU MIGHT LIKE

I cascaded four SN74HC595 shift registers to control 32 LEDs on 4 registers using 3 wires. I am adding a I2C 20×4 LCD screen to display the register and led values. I might add a standard 16×2 LCD screen to show up it is done.
A simple light meter. It’s not calibrated to any meaningful scale, but the digital readout shows a higher number the brighter is the light falling on the photoresistor.