Johns Van
Posts: 7
Joined: Tue Jul 04, 2023 11:41 am

multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 8:44 am

I have two tanks which of have fitted some stick on sensors to measure the levels,. (5 on each tanks)

I want the pico to monitor these and display a webpage that is run of the pico.
I had someone on Fiverr help me with the code, but after 10 attempts at writing (without him testing his code first) and all failed, so I cancelled it and tried fixing it myself. After rewriting all the code, I now have the website part working, however, with all the IF statements, unless the the last statement is active, none of the others work.
I added a POWERON pin status as the last one, so this is enabled at startup and then enables all the other pins to function, however, they will only work in the order they are written from the last to the first . As both tanks readings need to be independent of each other, I can find away to separate the two tank codes so they are not dependent on the IF statement below them being active.

I only have basic skill in coding so dont really understand the If ELIF and ELSE functions so out of my depth as to how to get it to work

Code: Select all

import time
import network
import socket
from machine import Pin
from utime import localtime
dateTimeObj = localtime()

#FRESH TANK
led = Pin("LED",Pin. OUT)
freshmt = Pin(1, Pin.IN, Pin.PULL_DOWN)      # tank empty red 
fresh1 = Pin(2, Pin.IN ,Pin.PULL_DOWN)       # tank 25% yellow 
fresh2 = Pin(3, Pin.IN ,Pin.PULL_DOWN)       # tank 50% green 
fresh3 = Pin(4, Pin.IN ,Pin.PULL_DOWN)       # tank 75% Green 
freshfull = Pin(5, Pin.IN, Pin.PULL_DOWN)    # tank full Blue 

#WASTE TANK
wastemt = Pin(6, Pin.IN ,Pin.PULL_DOWN)      #waste empty blue 
waste1 = Pin(7, Pin.IN ,Pin.PULL_DOWN)       #waste 25% full  green 
waste2 = Pin(8, Pin.IN ,Pin.PULL_DOWN)       #waste  50% full  green 
waste3 = Pin(9, Pin.IN, Pin.PULL_DOWN)       #waste  75%L full  green
wastefull = Pin(10, Pin.IN ,Pin.PULL_DOWN)   #waste FULL RED 
poweron = Pin(14, Pin.IN ,Pin.PULL_DOWN)

buzzer = Pin(15, Pin.OUT)     #alarm buzzer


# wifi code start
ssid = 'SSID'  # Replace with your actual wifi name
password = 'password'  # Replace with your actual password

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
# wifi code end
# HTML conten start




# Wait for connection or fail
max_wait = 10
while max_wait > 0:
    if wlan.isconnected():
        break
    max_wait -= 1
    print('waiting for connection...')
    time.sleep(1)

# Handle connection error
if not wlan.isconnected():
    raise RuntimeError('network connection failed')
else:
    print('Connected')
    status = wlan.ifconfig()
    print('IP = ' + status[0])

# Open socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(addr)
s.listen(1)
print('Listening on', addr)
html_response = html

# Listen for connections, serve client
while True:
    try:
        cl, addr = s.accept()
        print('Client connected from', addr)
        request = cl.recv(1024)
        request = str(request)

#fresh tank inputs below


        if freshfull.value() == 1:   #tank full
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-1"></div>', '<div class="box box-1 box-blue"></div>', 1) 
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if fresh3.value() == 1:  #tank 75%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-3"></div>', '<div class="box box-3 box-green"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if fresh2.value() == 1:  #tank 50%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-5"></div>', '<div class="box box-5 box-green"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if fresh1.value() == 1:  #tank 25%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-7"></div>', '<div class="box box-7 box-yellow"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if freshmt.value() == 1:  #Tank empty
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-9"></div>', '<div class="box box-9 box-red"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

# waste tank inputs below

        if wastefull.value() == 1:   #tank full
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-2"></div>', '<div class="box box-2 box-red"></div>', 1) 
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if waste3.value() == 1:   #tank 75%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-4"></div>', '<div class="box box-4 box-yellow"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)

        if waste2.value() == 1:   #tank 50%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-6"></div>', '<div class="box box-6 box-green"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)
            
        if waste1.value() == 1:    #tank 25%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-8"></div>', '<div class="box box-8 box-green"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)
            
        if wastemt.value() == 1:    #tank empty
            buzzer.value(0)
            led.value(1)
            html_response = html_response.replace('<div class="box box-10"></div>', '<div class="box box-10 box-blue"></div>', 1)   
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)
            
            
        if poweron.value() == 1:   # this being the last and alwasy on only way to get the others to work
            html_response = html_response.replace('<div class="box box-14"></div>', '<div class="box box-14 box-orange"></div>', 1)   
            buzzer.value(1)
            led.value(0)
        else:
            html_response = html
            buzzer.value(0)
            led.value(0)
            
        # Send the modified HTML response with or without the "box-red" class
        cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
        cl.send(html_response)
        cl.close()

    except OSError as e:
        cl.close()
        print('Connection closed')







Thank you

John
Attachments
screen.jpg
screen.jpg (228.87 KiB) Viewed 496 times

ame
Posts: 8217
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 8:48 am

The problem stems from the fact that you only have one html_response. It's possible that several conditions in your code will set html_response to a certain value, replacing any earlier value.

By the time you get to here, html_response will contain the last value that was assigned.

Code: Select all

# Send the modified HTML response with or without the "box-red" class
        cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
        cl.send(html_response)
        cl.close()
Oops. Edited to add, what is the value of html here?

Code: Select all

html_response = html
Oh no, not again.

Johns Van
Posts: 7
Joined: Tue Jul 04, 2023 11:41 am

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 10:12 am

Thanks for the replay Ame, unfortunately these are the bits I dont know and are legacy from the failed attempts.

I have tried to research the HTML_Response but don't know enough to understand how to use them to make things work> I have tried removing that one line and it makes things worse.

gordon77
Posts: 7740
Joined: Sun Aug 05, 2012 3:12 pm

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 2:20 pm

Can you show us the HTML section of your code so it can be tested ?
Last edited by gordon77 on Mon Sep 25, 2023 7:08 am, edited 1 time in total.

Johns Van
Posts: 7
Joined: Tue Jul 04, 2023 11:41 am

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 2:45 pm

Here is the html code

Code: Select all

   
   
   html = """<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tank Levels</title>
    <style>
        /* Reset some default styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Global Styles */
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            display: flex;
            justify-content: center; /* Center horizontally */
            align-items: center; /* Center vertically */
            height: 100vh; /* Full viewport height */
        }

        .main-container {
            width: 800px;
            height: 480px;
            background-color: black;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        }

        /* Navigation Menu Styles */
        .main-container > div:first-child {
            display: flex;
            justify-content: space-between;
            background-color: black;
            color: white;
            border-radius: 5px 5px 0 0;
            top: 50%;
        }

        .main-container a {
            text-decoration: none;
            color: white;
            padding: 20px 15px;
            background-color: blue;
            border-radius: 0 0 5px 5px;
        }

        .level-text {
            color: yellow;
            padding: 20px 15px;
            background-color: black;
            font-size: 30px;
        }

        /* Tank Levels Styles */
        .main-container > div:nth-child(2) {
            background-color: black;
            text-align: center;
            border-radius: 0 0 5px 5px;
        }

        /* Box Styles */
        .box {
            width: 100px;
            height: 50px;
            background-color: lightblue;
            border: 2px solid #000;
            margin: 0px auto;
            text-align: center;
            line-height: 50px; /* Adjusted line-height */
            font-weight: bold;
            font-size: 14px;
        }

        /* Container Grid Styles */
        .container {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2px;
            background-color: #000;
        }

        /* Cell Styles */
        .cell {
            background-color: #f2f2f2;
            border: 2px solid #ddd;
            padding: 10px;
            text-align: center;
            font-weight: bold;
        }

        .text {
            color: white;
            font-size: 14px;
            margin-left: -40px; /* Adjusted margin-left */
            margin-top: 20px;
        }

        /* Special style for empty cells */
        .text:contains("EMPTY") {
            color: #ff0000; /* Red for empty cells */
        }

        /* Tank Levels Styles */
        .tank-levels {
            display: flex;
            background-color: black;
            justify-content: flex-end;
            text-align: center;
            border-radius: 0 0 5px 5px;
            color: white;
        }

        /* Tank Styles */
        .tank1 {
            padding: 20px 0px;
            font-weight: bold;
            margin-right: 270px;
        }

        .tank2 {
            padding: 20px 0px;
            font-weight: bold;
            margin-right: 250px;
        }
        .box-red {background-color: red !important;}
        .box-green {background-color: green !important;}
        .box-yellow {background-color: yellow !important;}
        .box-blue {background-color: blue !important;}
        .box-orange {background-color: orange !important;}
        
        
    </style>
</head>
<body>
    <div class="main-container">
        <!-- Navigation Menu -->
        <div>
            <a href="#">MAIN SCREEN</a>
            <p class="level-text">TANK LEVELS</p>
            <a href="#">FAN SCREEN</a>
        </div>
        <!-- Tank Levels -->
        <div class="tank-levels">
            <div class="tank1">
                <p>FRESH TANK</p>
            </div>
            <div class="tank2">
                <p>WASTE TANK</p>
            </div>
        </div>
        <!-- Container Grid -->
        <div class="container">
            <!-- Row 1 -->
            <div class="box box-1"></div>
            <div class="text">FULL</div>
            <div class="box box-2"></div>
            <div class="text">FULL</div>
            <!-- Row 2 -->
            <div class="box box-3"></div>
            <div class="text">75%</div>
            <div class="box box-4"></div>
            <div class="text">75%</div>
            <!-- Row 3 -->
            <div class="box box-5"></div>
            <div class="text">50%</div>
            <div class="box box-6"></div>
            <div class="text">50%</div>
            <!-- Row 4 -->
            <div class="box box-7"></div>
            <div class="text">25%</div>
            <div class="box box-8"></div>
            <div class="text">25%</div>
            <!-- Row 5 -->
            <div class="box box-9"></div>
            <div class="text">EMPTY</div>
            <div class="box box-10"></div>
            <div class="text">EMPTY</div>
             <div class="box box-14"></div>
            <div class="text"></div>
        </div>
    </div>
</body>
</html>
"""

   
   

gordon77
Posts: 7740
Joined: Sun Aug 05, 2012 3:12 pm

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 3:14 pm

try this...

Code: Select all

import time
import network
import socket
from machine import Pin
from utime import localtime
dateTimeObj = localtime()

#FRESH TANK
led = Pin("LED",Pin. OUT)
freshmt = Pin(1, Pin.IN, Pin.PULL_DOWN)      # tank empty red 
fresh1 = Pin(2, Pin.IN ,Pin.PULL_DOWN)       # tank 25% yellow 
fresh2 = Pin(3, Pin.IN ,Pin.PULL_DOWN)       # tank 50% green 
fresh3 = Pin(4, Pin.IN ,Pin.PULL_DOWN)       # tank 75% Green 
freshfull = Pin(5, Pin.IN, Pin.PULL_DOWN)    # tank full Blue 

#WASTE TANK
wastemt = Pin(6, Pin.IN ,Pin.PULL_DOWN)      #waste empty blue 
waste1 = Pin(7, Pin.IN ,Pin.PULL_DOWN)       #waste 25% full  green 
waste2 = Pin(8, Pin.IN ,Pin.PULL_DOWN)       #waste  50% full  green 
waste3 = Pin(9, Pin.IN, Pin.PULL_DOWN)       #waste  75%L full  green
wastefull = Pin(10, Pin.IN ,Pin.PULL_DOWN)   #waste FULL RED 
poweron = Pin(14, Pin.IN ,Pin.PULL_DOWN)

buzzer = Pin(15, Pin.OUT)     #alarm buzzer


# wifi code start
ssid = ''  # Replace with your actual wifi name
password = ''  # Replace with your actual password

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
# wifi code end
# HTML conten start
   
   
html = """<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="2" >
    <title>Tank Levels</title>
    <style>
        /* Reset some default styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Global Styles */
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            display: flex;
            justify-content: center; /* Center horizontally */
            align-items: center; /* Center vertically */
            height: 100vh; /* Full viewport height */
        }

        .main-container {
            width: 800px;
            height: 480px;
            background-color: black;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        }

        /* Navigation Menu Styles */
        .main-container > div:first-child {
            display: flex;
            justify-content: space-between;
            background-color: black;
            color: white;
            border-radius: 5px 5px 0 0;
            top: 50%;
        }

        .main-container a {
            text-decoration: none;
            color: white;
            padding: 20px 15px;
            background-color: blue;
            border-radius: 0 0 5px 5px;
        }

        .level-text {
            color: yellow;
            padding: 20px 15px;
            background-color: black;
            font-size: 30px;
        }

        /* Tank Levels Styles */
        .main-container > div:nth-child(2) {
            background-color: black;
            text-align: center;
            border-radius: 0 0 5px 5px;
        }

        /* Box Styles */
        .box {
            width: 100px;
            height: 50px;
            background-color: lightblue;
            border: 2px solid #000;
            margin: 0px auto;
            text-align: center;
            line-height: 50px; /* Adjusted line-height */
            font-weight: bold;
            font-size: 14px;
        }

        /* Container Grid Styles */
        .container {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2px;
            background-color: #000;
        }

        /* Cell Styles */
        .cell {
            background-color: #f2f2f2;
            border: 2px solid #ddd;
            padding: 10px;
            text-align: center;
            font-weight: bold;
        }

        .text {
            color: white;
            font-size: 14px;
            margin-left: -40px; /* Adjusted margin-left */
            margin-top: 20px;
        }

        /* Special style for empty cells */
        .text:contains("EMPTY") {
            color: #ff0000; /* Red for empty cells */
        }

        /* Tank Levels Styles */
        .tank-levels {
            display: flex;
            background-color: black;
            justify-content: flex-end;
            text-align: center;
            border-radius: 0 0 5px 5px;
            color: white;
        }

        /* Tank Styles */
        .tank1 {
            padding: 20px 0px;
            font-weight: bold;
            margin-right: 270px;
        }

        .tank2 {
            padding: 20px 0px;
            font-weight: bold;
            margin-right: 250px;
        }
        .box-red {background-color: red !important;}
        .box-green {background-color: green !important;}
        .box-yellow {background-color: yellow !important;}
        .box-blue {background-color: blue !important;}
        .box-orange {background-color: orange !important;}
        
        
    </style>
</head>
<body>
    <div class="main-container">
        <!-- Navigation Menu -->
        <div>
            <a href="#">MAIN SCREEN</a>
            <p class="level-text">TANK LEVELS</p>
            <a href="#">FAN SCREEN</a>
        </div>
        <!-- Tank Levels -->
        <div class="tank-levels">
            <div class="tank1">
                <p>FRESH TANK</p>
            </div>
            <div class="tank2">
                <p>WASTE TANK</p>
            </div>
        </div>
        <!-- Container Grid -->
        <div class="container">
            <!-- Row 1 -->
            <div class="box box-1"></div>
            <div class="text">FULL</div>
            <div class="box box-2"></div>
            <div class="text">FULL</div>
            <!-- Row 2 -->
            <div class="box box-3"></div>
            <div class="text">75%</div>
            <div class="box box-4"></div>
            <div class="text">75%</div>
            <!-- Row 3 -->
            <div class="box box-5"></div>
            <div class="text">50%</div>
            <div class="box box-6"></div>
            <div class="text">50%</div>
            <!-- Row 4 -->
            <div class="box box-7"></div>
            <div class="text">25%</div>
            <div class="box box-8"></div>
            <div class="text">25%</div>
            <!-- Row 5 -->
            <div class="box box-9"></div>
            <div class="text">EMPTY</div>
            <div class="box box-10"></div>
            <div class="text">EMPTY</div>
             <div class="box box-14"></div>
            <div class="text"></div>
        </div>
    </div>
</body>
</html>
"""

   
   



# Wait for connection or fail
max_wait = 10
while max_wait > 0:
    if wlan.isconnected():
        break
    max_wait -= 1
    print('waiting for connection...')
    time.sleep(1)

# Handle connection error
if not wlan.isconnected():
    raise RuntimeError('network connection failed')
else:
    print('Connected')
    status = wlan.ifconfig()
    print('IP = ' + status[0])

# Open socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(addr)
s.listen(1)
print('Listening on', addr)
html_response = html

# Listen for connections, serve client
while True:
    try:
        cl, addr = s.accept()
        print('Client connected from', addr)
        request = cl.recv(1024)
        request = str(request)

#fresh tank inputs below


        if freshfull.value() == 1:   #tank full
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-1"></div>', '<div class="box box-1 box-blue"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-1 box-blue"></div>', '<div class="box box-1"></div>', 1)
            buzzer.value(0)
            led.value(0)

        if fresh3.value() == 1:  #tank 75%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-3"></div>', '<div class="box box-3 box-green"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-3 box-green"></div>', '<div class="box box-3"></div>', 1)
            buzzer.value(0)
            led.value(0)
              

        if fresh2.value() == 1:  #tank 50%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-5"></div>', '<div class="box box-5 box-green"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-5 box-green"></div>', '<div class="box box-5"></div>', 1)
            buzzer.value(0)
            led.value(0)


        if fresh1.value() == 1:  #tank 25%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-7"></div>', '<div class="box box-7 box-yellow"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-7 box-yellow"></div>', '<div class="box box-7"></div>', 1)
            buzzer.value(0)
            led.value(0)


        if freshmt.value() == 1:  #Tank empty
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-9"></div>', '<div class="box box-9 box-red"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-9 box-red"></div>', '<div class="box box-9"></div>', 1)
            buzzer.value(0)
            led.value(0)


# waste tank inputs below

        if wastefull.value() == 1:   #tank full
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-2"></div>', '<div class="box box-2 box-red"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-2 box-red"></div>', '<div class="box box-2"></div>', 1)
            buzzer.value(0)
            led.value(0)


        if waste3.value() == 1:   #tank 75%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-4"></div>', '<div class="box box-4 box-yellow"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-4 box-yellow"></div>', '<div class="box box-4"></div>', 1)
            buzzer.value(0)
            led.value(0)

        if waste2.value() == 1:   #tank 50%
            buzzer.value(1)
            led.value(0)
            html_response = html_response.replace('<div class="box box-6"></div>', '<div class="box box-6 box-green"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-6 box-green"></div>', '<div class="box box-6"></div>', 1)
            buzzer.value(0)
            led.value(0)
            
        if waste1.value() == 1:    #tank 25%
            buzzer.value(1)
            led.value(1)
            html_response = html_response.replace('<div class="box box-8"></div>', '<div class="box box-8 box-green"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-8 box-green"></div>', '<div class="box box-8"></div>', 1)
            buzzer.value(0)
            led.value(0)

            
        if wastemt.value() == 1:    #tank empty
            buzzer.value(0)
            led.value(1)
            html_response = html_response.replace('<div class="box box-10"></div>', '<div class="box box-10 box-blue"></div>', 1)
        else:
            html_response = html_response.replace('<div class="box box-10 box-blue"></div>', '<div class="box box-10"></div>', 1)
            buzzer.value(0)
            led.value(0)
            
        if poweron.value() == 1:   # this being the last and alwasy on only way to get the others to work
            html_response = html_response.replace('<div class="box box-14"></div>', '<div class="box box-14 box-orange"></div>', 1)   
            buzzer.value(1)
            led.value(0)
        else:
            html_response = html_response.replace('<div class="box box-14 box-orange"></div>', '<div class="box box-14"></div>', 1)
            buzzer.value(0)
            led.value(0)
        

            
        # Send the modified HTML response with or without the "box-red" class
        cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
        cl.send(html_response)
        cl.close()

    except OSError as e:
        cl.close()
        print('Connection closed')
Last edited by gordon77 on Mon Sep 25, 2023 10:12 am, edited 2 times in total.

Johns Van
Posts: 7
Joined: Tue Jul 04, 2023 11:41 am

Re: multiple input IFs only work if Last input is active.

Sun Sep 24, 2023 11:54 pm

Gordon, you sir are a legend.

That works perfectly. You have made me a happy (old ) man


I ran a compare between my original and yours to find where the problems were.

I have learned a little more about coding.

Thank you so much,

:D :D

gordon77
Posts: 7740
Joined: Sun Aug 05, 2012 3:12 pm

Re: multiple input IFs only work if Last input is active.

Mon Sep 25, 2023 10:16 am

Pleased it worked OK.

Note I have added <meta http-equiv="refresh" content="2" > so the webpage will automatically update.

Johns Van
Posts: 7
Joined: Tue Jul 04, 2023 11:41 am

Re: multiple input IFs only work if Last input is active.

Mon Sep 25, 2023 11:44 am

Yes I had that line and removed it during my troubleshooting. New to this kind of coding so was grasping at straws there for a while.

Thanks again

Return to “MicroPython”