Skip to content

I upload here my smaller Arduino or microcontroller related projects.

Notifications You must be signed in to change notification settings

kerezsiz42/ESP8266

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

My ESP8266 Projects

nodemcu

Toggle LED_BUILTIN trough Wifi

You can easily control the pins of an ESP8266 even from the other end of the world. This c++ function toggles the built in LED on and off (polarity is reversed because this LED is pulled to VCC):

server.on("/toggle", []() {
    server.send(200, "text/html", "toggled");
    if(digitalRead(LED_BUILTIN)) {
      digitalWrite(LED_BUILTIN, 0);
    } else {
      digitalWrite(LED_BUILTIN, 1);
    }
  });

On the client side one can simply send a fetch command to the /toggle endpoint:

<meta name='viewport' content='width=device-width, initial-scale=1'>
<style>body{text-align:center;}button{padding:20px;}</style>
<h1>Toggle LED_BUILTIN</h1>
<button id='button' onclick='toggle()'>Toggle</button>
<script>
const toggle = () => {
	fetch('http://192.168.0.179/toggle');
}
</script>

About

I upload here my smaller Arduino or microcontroller related projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published