/*************************************************
This simulation mimics an electron jumping between energy
levels and emitting light in the visible spectrum, with
the emitted colors corresponding to specific wavelengths.
The serial output provides a visual explanation of what
each LED
represents.
arind patil 12/9/24 copywrite under MIT liscence
discussion https://chatgpt.com/share/76dbcc0a-59bd-4bb5-a24c-f82a99152ae7
********************************************/
// Pin definitions for each LED color
int redLED = 2; // Red LED pin
int greenLED = 3; // Green LED pin
int yellowLED = 4; // Yellow LED pin
int blueLED = 5; // Blue LED pin
int violetLED = 6; // Violet LED pin
int whiteLED = 7; // White LED pin
// Time delay for showing each color (in milliseconds)
int delayTime = 2000; // 1 second delay for each transition
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Set LED pins as OUTPUT
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(blueLED, OUTPUT);
pinMode(violetLED, OUTPUT);
pinMode(whiteLED, OUTPUT);
}
void loop() {
// Display red LED
digitalWrite(redLED, HIGH);
Serial.println("Color: Red, Wavelength: 620-750 nm");
delay(delayTime);
digitalWrite(redLED, LOW);
// Display green LED
digitalWrite(greenLED, HIGH);
Serial.println("Color: Green, Wavelength: 495-570 nm");
delay(delayTime);
digitalWrite(greenLED, LOW);
// Display yellow LED
digitalWrite(yellowLED, HIGH);
Serial.println("Color: Yellow, Wavelength: 570-590 nm");
delay(delayTime);
digitalWrite(yellowLED, LOW);
// Display blue LED
digitalWrite(blueLED, HIGH);
Serial.println("Color: Blue, Wavelength: 450-495 nm");
delay(delayTime);
digitalWrite(blueLED, LOW);
// Display violet LED
digitalWrite(violetLED, HIGH);
Serial.println("Color: Violet, Wavelength: 380-450 nm");
delay(delayTime);
digitalWrite(violetLED, LOW);
// Display white LED
digitalWrite(whiteLED, HIGH);
Serial.println("Color: White, Wavelength: Combination of all visible wavelengths");
delay(delayTime);
digitalWrite(whiteLED, LOW);
// Add a brief pause between cycles
delay(2000);
}