jharwinbarrozo / Push Button

Files

Pins

Symbol

PCB

Open in Flux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Howdy ๐Ÿ‘‹.
// If you are new to writing code in Flux make sure to check out our get started docs: https://docs.flux.ai/reference/introduction 
// We also have a Flux Slack Community in case you need help: https://join.slack.com/t/fluxcommunity/shared_invite/zt-p48n941f-wzQ06kGmuFJ2HXnGYT1JkA 
// To infinity and beyond ๐Ÿš€ 
const p1TerminalId = "0860dc5d-facf-3e33-1d57-6791399c1fa3"; //P1
const p2TerminalId = "020cf3fc-777c-d543-49b3-8c4a9fc59854"; //P2
const p1Terminal = flux.getNodeById(p1TerminalId, "elementTerminal");
const p2Terminal = flux.getNodeById(p2TerminalId, "elementTerminal");
flux.on("setup", () => {
    const pushSwitch = flux.controls.find(control => control.name === "Momentary Switch");
    if (pushSwitch?.value) {
        flux.currentSymbol = "push-button-closed";
         flux.simulationModel = simModel(true);
    } else {
        flux.currentSymbol = "push-button-open";
        flux.simulationModel = simModel(false);
    }
});
flux.on("inputChange", (e) => {
    if (e.control_name === "Momentary Switch") {
        if (e.value) {
            flux.currentSymbol = "push-button-closed";
            flux.simulationModel = simModel(false);
        } else
        {
            flux.currentSymbol = "push-button-open";
            flux.simulationModel = simModel(false);

Reviews