Hallo,
ich nähere mich zum Ende von meinem Project und wollte so viel Infos wie nötig zur Verfügung stellen für die nachfolgenden Tüftler.
In diesem Project handelt sich um eine einfache Steuerung des LED mit max 1000 mA Strom Annahme mit Potentiometer.
Schöne Grüße
Verkabelung.pdf (23,9 KB)
#include "rgb_lcd.h"
#include <Wire.h>
rgb_lcd lcd;
const int colorR = 4;
const int colorG = 2;
const int colorB = 115;
const int analogInPin = A0; //Potentiometer
int Helligkeit;
int LED =6; //LED Digitalen PIN
int ReglerWert=0;
int Strom;
void setup() {
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
lcd.setCursor(0, 0);
lcd.print("HAllo");
lcd.setCursor(0, 1);
lcd.print(":)");
delay(1000);
for (int positionCounter = 0; positionCounter < 8; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(500);
}
// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 8; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(500);
}
delay(2000);
lcd.clear();
lcd.setRGB(colorR, colorG, colorB);
}
void loop() {
ReglerWert = analogRead(analogInPin);
//Helligkeit = map(ReglerWert, 0, 1023, 0, 100);
Helligkeit = map(ReglerWert, 1023, 0, 0, 100);
Strom = map(ReglerWert, 1023, 0, 0, 620);
lcd.setCursor(6,0 );
lcd.print("Helligkeit");
lcd.setCursor(0,1);
lcd.print("455nm");
if (Strom>= 100) {
lcd.setCursor(11,1);
lcd.print(Strom);
}
if (Strom <100 & Strom>= 10) {
lcd.setCursor(11,1);
lcd.print(" ");
lcd.setCursor(12,1);
lcd.print(Strom);
}
if (Strom <10) {
lcd.setCursor(11,1);
lcd.print(" ");
lcd.setCursor(13,1);
lcd.print(Strom);
}
lcd.setCursor(14,1);
lcd.print("mA");
// LED mit analogWrite() zum Leuchten bringen
analogWrite(LED, ReglerWert / 4);
//analogWrite (LED, map(ReglerWert ,0,1023,0,255));
Serial.print(Helligkeit);
Serial.println("%");
Serial.println(ReglerWert);
lcd.setCursor(0, 0);
lcd.print(Helligkeit);
lcd.setCursor(3, 0);
lcd.print("%");
lcd.setCursor(2,0); // set cursor
if (Helligkeit <100) lcd.print(" ");
lcd.setCursor(1,0); // set cursor
if (Helligkeit <10) lcd.print(" ");
if (Helligkeit >98) {
lcd.setCursor(0, 0);
lcd.print("100");
}
}