Previous

This is the 18th example in a series of examples for arduino beginners. For more examples click these buttons or select a example from the grid at the bottom.

Next

Description

This is the 18th example in our arduino for beginners series and in this one we implement a programmable voltage source. The desired voltage is entered on the serial monitor and the same is output in hardware using the PWM output on the arduino.

Code

int pwmPin = 9;
int val1;
int volt;
void setup()
{
Serial.begin(9600);
}
void loop()
{

if (Serial.available())
{
val1 = Serial.read();
}
Serial.println(val1);
volt = map(val1-48,0,5,0,255);
analogWrite(pwmPin, volt);
Serial.println(volt);
}

Pictures / Video

Arduino for Beginners - Programmable Voltage Source
Arduino for Beginners - Programmable Voltage Source
Arduino for Beginners - Programmable Voltage Source

Files

Arduino SketchFritzing File

Share This

Other Examples

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |

Other Learning Resources