Decimal To Binary simple Circuit - Arduino
Video Link: - Click Here For Video
Decimal To Binary simple Circuit - Arduino Circuit: -
Decimal To Binary simple Circuit - Arduino Programming: -
Arduino IDE Program
// Define LED pins
const int ledPins[] = {6, 7, 8, 9};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) {
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], LOW); // Initialize LEDs as off
}
}
void loop() {
if (Serial.available() > 0) {
int decNumber = Serial.parseInt(); // Read decimal input from serial monitor
if (decNumber >= 0 && decNumber <= 15) {
// Convert decimal to binary and control LEDs
for (int i = 0; i < 4; i++) {
int bitValue = (decNumber >> i) & 1; // Extract each bit
digitalWrite(ledPins[i], bitValue);
}
Serial.print("Decimal input: ");
Serial.println(decNumber);
} else {
Serial.println("Invalid input. Enter a number between 0 and 15.");
}
}
}
-----------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #pro #IDM #Solutions #Hack
0 Comments