Introduction: How to Make Arduino Constant Load
How to make arduino constant current load
Step 1: Prepare Your Laptop and Arduino
Go to arduino.cc and install Arduino IDE i recomend you to download version 1.6.5. .
Step 2: Put It Together
Source of mosfet goes to ground.Drain to 10W 15 ohm resistor other side of the resistor goes to + of supply what you need to load.Most left side of potentiometer goes to ground. Midlle terminal goes to A0 of Arduino.Most right terminal of potentiometer goes to 5V.Gate of Mosfet goes to pin digital pin3.
Step 3: Program Your Arduino
here is code its modified version of example code diming
/*
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* Gate of mosfet connected from digital pin 3
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
*/int outputValue = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("potenciometer = " );
Serial.print(sensorValue);
Serial.print("\t MOSFET = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
}
/*
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* Gate of mosfet connected from digital pin 3
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
*/int outputValue = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("potenciometer = " );
Serial.print(sensorValue);
Serial.print("\t MOSFET = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
}
Step 4: Test It
I had 12volt battery pack for test
Step 5: ATTiny Version
In my home country is attiny very expensive 3.50eur each. Coming Soon