Day 15? Oct 17

For lab we had to control a motor using a potentiometer,we also included a switch. Here's our code



//Simple Motor Speed Control Program
const int MOTOR=9;
const int POT=0;
int min_val=0;
int max_val=1023;
int val=0;//Motor on Digital Pin 9
void setup()
{
 pinMode (MOTOR, OUTPUT);


}
void loop()
{
val=analogRead(POT);
   val=map(val,min_val,max_val,0,255);


  analogWrite(MOTOR,val);

}
Here's a link to the thing working

We didn't have homework today

Comments

Popular posts from this blog

Day 5

Day 22 Nov 14

Day 21 Nov 9