Using a webpage to control leds connected to a microcontroller. Just using a variable to
substitute for document.getElementById('ID_LED_0')
EDIT: Also get err in console: DevTools failed to load source map: Could not load content for chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/browser-polyfill.js.map: System error: net::ERR_FILE_NOT_FOUND
this works:
But this doesn't
substitute for document.getElementById('ID_LED_0')
EDIT: Also get err in console: DevTools failed to load source map: Could not load content for chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/browser-polyfill.js.map: System error: net::ERR_FILE_NOT_FOUND
this works:
Code:
<scipt>
document.getElementById('ID_LED_0').addEventListener('click', led_changed);
document.getElementById('ID_LED_1').addEventListener('click', led_changed);
document.getElementById('ID_LED_2').addEventListener('click', led_changed);
function led_changed() {
if(document.getElementById('ID_LED_1').checked == true) {
l_LED_selected = 1;
console.log(l_LED_selected);
var msg = { type: 'LED_selected', value: l_LED_selected};
Socket.send(JSON.stringify(msg));
}
</script>
But this doesn't
Code:
<script>
var led_1=document.getElementById('ID_LED_1');
led_1.addEventListener('click', led_changed);
function led_changed() {
if(led_1.checked == true) {
l_LED_selected = 1;
console.log(l_LED_selected);
var msg = { type: 'LED_selected', value: l_LED_selected};
Socket.send(JSON.stringify(msg));
} //EDIT WAS NOT PRESENT IN ORIGINAL POST
}
</script>
Last edited: