Last active
November 17, 2023 07:52
-
-
Save MartinRGB/fc13d2a550aabf76ab8ed585ec16ac36 to your computer and use it in GitHub Desktop.
Revisions
-
MartinRGB revised this gist
Nov 17, 2023 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ <img src="https://user-images.githubusercontent.com/7036706/283719014-0f603f3d-f833-41f0-be34-d5c6a06a21f0.png" width="50%" height="50%"/> <img src="https://user-images.githubusercontent.com/7036706/283719916-db754e49-fdb8-4f64-ad55-185a38fab2dd.jpg" width="50%" height="50%"/> ```c -
MartinRGB created this gist
Nov 17, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@  ```c #define ROTATOR_PIN A0 #define BUTTON_PIN 10 #define WL_PIN 3 #define CL_PIN 5 float rotatorValue; //variable to store sensor value byte buttonState; float mapBrightnessValue; float mapWarmValue = 1; float mapColdValue = 1; void setup() { Serial.begin(9600); pinMode(ROTATOR_PIN, INPUT); pinMode(BUTTON_PIN, INPUT); pinMode(WL_PIN,OUTPUT); pinMode(CL_PIN,OUTPUT); } void loop() { buttonState = digitalRead(BUTTON_PIN); rotatorValue = analogRead(ROTATOR_PIN); Serial.println(rotatorValue); if (buttonState == HIGH) { Serial.println("Button is pressed"); mapBrightnessValue = map(rotatorValue,0,1023,0,42); analogWrite(WL_PIN, mapBrightnessValue * 1.5); analogWrite(CL_PIN, (42 - mapBrightnessValue)* 1.5); } else { Serial.println("Button is not pressed"); mapBrightnessValue = map(rotatorValue,0,1023,0,42); analogWrite(WL_PIN, mapBrightnessValue); analogWrite(CL_PIN, mapBrightnessValue); } } ```