Download presentation
Presentation is loading. Please wait.
1
Appliace Remote Control
Dr. Veton Kepuska
2
Required Parts Arduino MEGA x1 RF appliance Remote Control x1
Prototyping Shield x1 5V Reed relays x4 1N4001 power diodes or similar x4 PCB-mount male connectors x4 Line-mount female connectors x4 Ribbon cable 10cm x1
3
void loop() { // The raw character read from the serial port byte val; // Integer conversion of channel ID int channel; //Check if a value has been send by the host if (Serial.available()) { val = Serial.read(); // convert ASCII value to binary channel = (int) val-48; if (channel > 0 && channel <= pinCount) { // Pulse the apropriate button pulseOutput(channel); } //Use pins 5 through 12 as the digital outputs int pinMap[] = {5, 6, 7, 8, 9, 10, 11, 12}; byte pinCount = sizeof(pinMap)/sizeof(pinMap[0]); // Number of milliseconds to hold the outputs on int buttonPressTime = 250; void setup() { // Open the serial connection to listen for commands from // the host Serial.being(38500); int count = 0; // variable to store currenct array position // Set up the pins as outputs and force them LOW for (count; count < pinCount; count++) { pintMode(outputArray[count], OUTPUT); digitalWrite(outputArray[count], LOW); }
4
void pulseOutput(int channel) { Serial. Print("Ouput "); Serial
void pulseOutput(int channel) { Serial.Print("Ouput "); Serial.Print(channel); Serial.Println(" ON"); digitlaWrite(outputArray[channel - 1], HIGH); delay(buttonPressTime); digitalWrite(outputArray[channel - 1], LOW); Serial.Println(" OFF"); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.