User:Yoana Buzova/mrSTOCK2

From XPUB & Lens-Based wiki
< User:Yoana Buzova
Revision as of 18:22, 16 March 2013 by Yoana Buzova (talk | contribs) (Created page with "DC motoro speed control with IR sensor code: int transistorPin = 9; // motor connected to digital pin 9 int sensor = 3; // sensor connected to analog pin 3 ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

DC motoro speed control with IR sensor

code:

 int transistorPin = 9;      // motor connected to digital pin 9
 
 int sensor = 3;   // sensor connected to analog pin 3
 
 int sensorValue = 0;         // variable to store the read value
 
 
 
 void setup()
 
 {
  Serial.begin (115200);  
   pinMode(transistorPin, OUTPUT);   // sets the pin as output
 
 }
 
 
 
 void loop()
 
 {
 
   sensorValue = analogRead(sensor);   // read the input pin
   sensorValue = map(sensorValue, 0, 1023, 100, 255);   //map values
   analogWrite(transistorPin, sensorValue); 
   Serial.println(sensorValue);
  
 }


Ir controlled DCmotor.jpg DCmotor+ard.jpg