Experimen 2: Reading a potentiometer.

 This experiment was made to test out a potentiometer. 

Potentiometer is a knob that regulates the amount of electricity that goes through a circuit. 





The purpose of this experiment was to make the Potentiometer control the blinking of the light, the more energy provided (5V) the more it blinks and then the blinking can't be seen because it is too quick. 

Code: 

int sensorPin = 0;    

int ledPin = 13;     

void setup() 

{  pinMode(ledPin, OUTPUT);  }

void loop() 

{  int sensorValue;

  sensorValue = analogRead(sensorPin);    

  digitalWrite(ledPin, HIGH);     

  delay(sensorValue);                                 

  digitalWrite(ledPin, LOW);      

  delay(sensorValue);  }




This is the result of the code

https://www.youtube.com/watch?v=MmtoccjWXAk


Breaking apart of the code: 

Code: 

int sensorPin = 0;    //the potentiometer was plugged to this pin, which was an analog, analog information in code goes straight through like a wave. Digital first gets transferred to 1 and 0's then turned into whatever you want so there will be an interval in between or the "glitch" can be explained because of this. 

int ledPin = 13;  //Back to the led pin we have used before.    

void setup() 

{  pinMode(ledPin, OUTPUT);  } led pin is given a power output function

void loop() //loop starts blinking on and off on is high, off is low. Loop gives it the forever feeling. 

{  int sensorValue; //this tells the sensor or meter to use the value it gives as the amount of power. We are using analog, therefore it is hands on action! remember the old radios turning knobs, that is what you were doing. Limiting and changing the amount of power it ran through it by turning the knob. This knob would change a dial that touched a metal on different parts. This is so cool! 

  sensorValue = analogRead(sensorPin);    

  digitalWrite(ledPin, HIGH);    // tells the led to turn on

  delay(sensorValue);        //  reads the value from the potentiometer to know the amount of delay per blink                       

  digitalWrite(ledPin, LOW);    // turns light off

  delay(sensorValue);  }  // reads the value from the potentiometer to know the amount of delay per blink                       

video explanation of what it does


Explanation of the code. 




Reflection
\
From this experiment what I gather was that the analog information is manual and can be accessed by turning knobs. Digital information is there by pressing buttons going up and down. STEPS per say. Digital information is converting analog information into 1's and 0s and creating a code that mimics that information. Analog is limited by the device that you will use. This is pretty awesome. That is why this was used on light switches that dimmed and volume knobs and radio dials. 


Volume knobs, light switches that dimmed the light. I have two lamps that when you touch them they have 3 different settings of light and brightness. 




In this case there must be two sensors, one giving the amounts levels and the other going up and down like a sequence. 



Comments

Popular posts from this blog

Teach the younglings to design their games! !!!!