Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LedPin 11
- String Read, myString;
- int PWM;
- void setup() {
- pinMode(LedPin, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- if (Serial.available()){ // If there's available Serial Data
- Read = Serial.readString(); // Read it as string
- Read.substring(0, "\n"); // Reading from the first index to the end of the Command line
- if(Read.indexOf(0) == "F" || Read.indexOf(0) == "f"){
- PWM = Read.substring(1, "\n").toInt(); //Reading the PWM and Turning it into ints
- digitalWrite(LedPin, PWM);
- }
- else if (Read.indexOf(0) == "B" || Read.indexOf(0) == "b"){
- digitalWrite(LedPin, LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment