Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Atmega 8 based device controller using arduino

View attachment 159713
Code:
/*
////////////////////////////////////
//////////Magnatron/////////////////
////////////////////////////////////
////magnatronelectronics@gmail.com//
////////////////////////////////////
////////////////////////////////////
*/
int val = 0;       // variable to store the data from the serial port
int rlyPin1 = 13;
int rlyPin2 = 12;
int rlyPin3 = 11;
int rlyPin4 = 10;
void setup()
{
  pinMode(rlyPin1,OUTPUT); //Declare relayPINs
  pinMode(rlyPin2,OUTPUT); //Declare relayPINs
  pinMode(rlyPin3,OUTPUT); //Declare relayPINs
  pinMode(rlyPin4,OUTPUT); //Declare relayPINs
  Serial.begin(9600); 
  Serial.print("Magnatron Technologies");
  delay(1000);
  Serial.print("Device Status : Initializing");
  for (int i=0; i <= 4; i++)
  {
    Serial.print('.');
    delay(10);     
  }
  Serial.print("System check: OK");
  delay(500);
}

void loop ()
{


  val = Serial.read();

  if (val != -1)
  {
    switch ( val)
    {  
    case 10 :   
      Serial.print("device 1 Status : OFF");
      rlyPin1=LOW;
      break;

    case 11:   
      Serial.print("device 1 Status : ON");
      rlyPin1=HIGH;
      break;

    case 20:   
      Serial.print("device 2 Status : ON");
      rlyPin2=LOW;
      break; 
    case 21:   
      Serial.print("device 2 Status : ON");
      rlyPin2=HIGH;
      break;

    case 30:   
      Serial.print("device 3 Status : ON");
      rlyPin3=LOW;
      break; 
    case 31:   
      Serial.print("device 3 Status : ON");
      rlyPin3=HIGH;
      break;

    case 40:   
      Serial.print("device 4 Status : ON");
      rlyPin4=LOW;
      break; 
    case 41:   
      Serial.print("device 4 Status : ON");
      rlyPin4=HIGH;
      break;  

    case 00:
      {
        Serial.print("device * Status : OFF");
        rlyPin1=LOW;
        rlyPin2=LOW;
        rlyPin3=LOW;
        rlyPin4=LOW;

      }
    case 44:
      {
        Serial.print("device * Status : ON");
        rlyPin1=HIGH;
        rlyPin2=HIGH;
        rlyPin3=HIGH;
        rlyPin4=HIGH;   
      }
    default:
      Serial.print("Error: Unrecognized character");

    }
  }
}

i had made this in 26/12/2010 for a small firm here. for my surprise, they use it 24/7 and worked perfectly with no error or mishap...
i think everyone should try this, after all its too simple!

Comments

There are no comments to display.

Part and Inventory Search

Blog entry information

Author
Magnatron
Read time
1 min read
Views
758
Last update

More entries in Uncategorized

Share this entry

Back
Top