PC based light intensity controller
To control light intensity through pc I developed an application in Microsoft visual studio and make it communicate to Arduino in order to send the PWM value that would control MOSFET via Arduino which in turn will control the intensity of LED lights I am controlling
you can download the application with code from this link https://drive.google.com/open?id=1eF3F2S-h_6_dHfn1JWRhsNyP-qgU3v1Y
you can find Arduino code for this project from this link https://drive.google.com/open?id=1siO2uxrQzuTkqgQhlFxDLr32zO34L7mf
connect the PWM output from Arduino pin 3 to gate of MOSFET which can high power LEDS.
if you want to copy arduino code directly here it is
String inData = "0";
String a = "0";
int k = 0;
float lux = 0.00,av=0.0048828125,lv;
long time1;
int h;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
pinMode(3,OUTPUT);
pinMode(A0,INPUT);
time1 = millis();
}
String a = "0";
int k = 0;
float lux = 0.00,av=0.0048828125,lv;
long time1;
int h;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
pinMode(3,OUTPUT);
pinMode(A0,INPUT);
time1 = millis();
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available())
{
char recieved = Serial.read();
inData += recieved;
// put your main code here, to run repeatedly:
while (Serial.available())
{
char recieved = Serial.read();
inData += recieved;
// Process message when new line character is recieved
if (recieved == '\n')
{
a = inData;
inData = ""; // Clear recieved buffer
}
}
//Serial.println(100);
h = k;
k = a.toInt();
if(k <= 50)
{
digitalWrite(13,LOW);
}
else
{
digitalWrite(13,HIGH);
}
if (recieved == '\n')
{
a = inData;
inData = ""; // Clear recieved buffer
}
}
//Serial.println(100);
h = k;
k = a.toInt();
if(k <= 50)
{
digitalWrite(13,LOW);
}
else
{
digitalWrite(13,HIGH);
}
lv = analogRead(A0);
lux = (250.000/(av*lv))-50.000 + 100;
while((millis() - time1) >= 1000)
{
Serial.println(int(lux));
time1 = millis();
}
if(k >= 990)
{
k = h;
}
analogWrite(3,k);
delay(100);
}
lux = (250.000/(av*lv))-50.000 + 100;
while((millis() - time1) >= 1000)
{
Serial.println(int(lux));
time1 = millis();
}
if(k >= 990)
{
k = h;
}
analogWrite(3,k);
delay(100);
}