Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#define analogInPin A0
#define pwmOutPin 5
uint16_t sensorValue,outputValue,percentValue;
void setup() {
pinMode(pwmOutPin,OUTPUT);
pinMode(analogInPin,INPUT);
}
void loop(){
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(pwmOutPin, outputValue);
}
Two 10K resistors in series equals one 20K resistor. Also, two 20K resistors in parallel equals one 10K resistor.im still waiting on my other resistors to come in the mail the 20k ohm
I was testing my 10k ohm resistors and they are saying there 10.12k ohm will these still work or did they send me the wrong ones im testing them with a ( 12864 Mega328 ESR Transistor Resistor Diode Capacitor Mosfet Tester )
#define analogInPin A0
#define pwmOutPin 5
uint16_t sensorValue,outputValue,percentValue;
void setup() {
pinMode(pwmOutPin,OUTPUT);
pinMode(analogInPin,INPUT);
}
void loop(){
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(pwmOutPin, outputValue);
}
#define analogInPin A0
#define PWM1 3
#define DIR1 5
uint16_t sensorValue,outputValue,percentValue;
void setup() {
pinMode(PWM1,OUTPUT);
pinMode(analogInPin,INPUT);
pinMode(DIR1,OUTPUT);
digitalWrite(DIR1,HIGH); //change HIGH to LOW if motor goes wrong way
}
void loop(){
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(PWM1, outputValue);
}
#define analogInPin A0
#define PWM1 3
#define DIR1 5
#define BATTERY A1
uint16_t sensorValue,outputValue,percentValue;
uint32_t batteryVoltage; //32 bit to prevent overflow
uint32_t tick=0;
void setup() {
Serial.begin(115200);
Serial.println("\n\n\n\nHello");
pinMode(PWM1,OUTPUT); //set the PWM pin to output
pinMode(analogInPin,INPUT); //set the potentiometer pin to input
pinMode(BATTERY,INPUT); //set the battery pin to input
pinMode(DIR1,OUTPUT); //set the dir pin to output
digitalWrite(DIR1,HIGH); //set it high - change HIGH to LOW if motor goes wrong way
}
void loop(){
// Read the PWM value of the input potentiometer.
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// map pump speed percent of full scale
percentValue = map (outputValue, 0, 255, 0, 100);
// change the analog out value:
analogWrite(PWM1, outputValue);
batteryVoltage=analogRead(BATTERY);
if((millis()-tick)>100){ //display 10 times per second
tick=millis();
Serial.print("Potentiometer Value = ");
Serial.println(sensorValue,DEC);
//convert battery reading to voltage (in milliVolts)
batteryVoltage*=15000; //*5000*3
batteryVoltage/=1024;
Serial.print("Battery Voltage = ");
Serial.println(batteryVoltage,DEC);
}
}