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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…