#include <Arduino.h>
// Pin definitions for RGB LED
int redPin = 11; // Red pin of RGB LED
int greenPin = 10; // Green pin of RGB LED
int bluePin = 9; // Blue pin of RGB LED
// Pin definitions for regular LEDs
int led1 = 13;
int led2 = 12;
int led3 = A1;
//port tester
int AnalogPin = A0;
float Vin;
int analogVal;
// Pin definitions for potentiometers
const int redPot = A2; // Potentiometer for red control
const int greenPot = A3; // Potentiometer for green control
const int bluePot = A4; // Potentiometer for blue control
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set RGB LED pins as outputs
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
// Set regular LED pins as outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// Turn on regular LEDs at startup
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
// Wait 2 seconds
delay(2000);
}
void loop() {
// Read values from potentiometers
int redValue = analogRead(redPot);
int greenValue = analogRead(greenPot);
int blueValue = analogRead(bluePot);
// Debug output
Serial.println("________________________________________");
Serial.print("Red: ");
Serial.print(redValue);
Serial.print(" Green: ");
Serial.print(greenValue);
Serial.print(" Blue: ");
Serial.println(blueValue);
Serial.println("________________________________________");
int redPWM =map(redValue, 0, 1023, 0, 255);
int greenPWM = map(greenValue, 0, 1023, 0, 255);
int bluePWM = map(blueValue, 0, 1023, 0, 255);
// Write PWM values to RGB LED pins
analogWrite(redPin, redPWM);
analogWrite(greenPin, greenPWM);
analogWrite(bluePin, bluePWM);
// Small delay to stabilize readings
delay(1000);
analogVal = analogRead(AnalogPin);
Vin= (analogVal *5.)/1023.;
Serial.println(Vin);
delay(500);
}