Line 1: Line 1:
{{#hsimg:1|100|External Image 1|http://exploreembedded.com/wiki/images/thumb/1/1a/XploreUNO1.jpeg/180px-XploreUNO1.jpeg}}
+
<syntaxhighlight>
{{#hsimg:1|100|External Image 1|http://exploreembedded.com/wiki/images/thumb/1/1a/XploreUNO1.jpeg/180px-XploreUNO1.jpeg}}
+
#include<reg51.h>  #define Motors P2#define Switches P1#define Forward 0x05#define Backward 0x0a#define Left 0x06#define Right 0x09#define stop 0x00void main(){  unsigned char SwitchInput;  Switches = 0x0f; //Configure Switches  as Input    Motors = 0X00;  //Configure both Motors as Output.  while(1)  {   SwitchInput = (0x0f & Switches);   //read switch status and mask lower byte.     switch(SwitchInput)   {   case 1: Motors = Forward; break;   case 2: Motors = Backward; break;   case 4: Motors = Left; break;   case 8: Motors = Right; break;   default: Motors =stop;   }  }}
{{#hsimg:1|100|External Image 1|http://exploreembedded.com/wiki/images/thumb/1/1a/XploreUNO1.jpeg/180px-XploreUNO1.jpeg}}
+
</syntaxhighlight>

Revision as of 13:28, 14 July 2014

#include<reg51.h>  #define Motors P2#define Switches P1#define Forward 0x05#define Backward 0x0a#define Left 0x06#define Right 0x09#define stop 0x00void main(){   unsigned char SwitchInput;   Switches = 0x0f; //Configure Switches  as Input    Motors = 0X00;  //Configure both Motors as Output.   while(1)   {	  SwitchInput = (0x0f & Switches); 	  //read switch status and mask lower byte.      switch(SwitchInput)	  {	  case 1: Motors = Forward; break;	  case 2: Motors = Backward; break;	  case 4: Motors = Left; break;	  case 8: Motors = Right; break;	  default: Motors =stop;	  }   }}