Circuit:



Code:



#include<reg51.h> 
sbit motor=P1^0; 
sbit pushbutton = P2^0; 
  
void main(){     
     pushbutton = 1;    
     while(1)     {        
        if(pushbutton == 1)        
        {                
            motor = 0XFF;         
        }        
        else                                                     
        {                
            motor = 0X00;         
        }    
    }
}