Variables
int assigns a certain value to a variable. For example, int sensorValue = 0, assigns the value 0 to the variable sensorValue.
const is a variable qualifier, modifying the behavior of the variable. const int follows the same principles of int, but the value of the variable cannot be changed later in the code. While the value of sensorValue and outputValue can be reassigned, analogInPin and analogOutPin will keep their respective values for the duration of the code.
In this step we want to initialize serial communications, communication with the PC, at 9600 bps. *9600 bits per second is the rate at which the communication in happening.
In void loop, “sensorValue = analogRead(analogInPin)” reads the analog value. “outputValue = map(sensorValue, 0, 1023, 0, 255)” maps the analog value to the range of the analog out. “analogWrite (analogOutPin, outputValue)” changes the analog out value. The Serial.print function prints the results of the POT to the serial:
Check to see if the circuit is correctly wired.
Check for extraneous or missing semicolons in Energia code.
Make sure the pins defined are PWM capable.
Comments
Please log in or sign up to comment.