1

I am trying to make a mini 8-bit binary display using Pimoroni Blinkt! on Raspberry Pi, and when I input a binary number, it outputs random numbers: I enter 00010011 and it outputs 4105, when it should output 00010011

My code:

from datetime import datetime
import blinkt
import time

blinkt.set_clear_on_exit(False)
blinkt.set_brightness(0.1)

current_pos_bin = 0
#minute = '00010011'
binNum = input('Binary number: ')
listBin = list(str(binNum))
print(binNum)
print(listBin)

for i in listBin:
        if i == '0':
                blinkt.set_pixel(current_pos_bin, 0, 0, 0)
                blinkt.show()
        elif i == '1':
                blinkt.set_pixel(current_pos_bin, 255, 255, 255)
                blinkt.show()
        else:
                print('error')
        print(current_pos_bin)
        current_pos_bin += 1
        #time.sleep(1)
blinkt.show()
2
  • Are you using Python2 by any chance? Nvm, I had a second think about it and you're most likely not. Commented Jun 13, 2020 at 10:38
  • Just put a proper shebang as the first line, i.e. #!/usr/bin/python3 and make the script executable with chmod +x YourScript.py then you can run it with ./YourScript.py Commented Jun 13, 2020 at 12:04

1 Answer 1

1

I am using python 3.8. I tried your code without using the blink library. It worked fine for me. Maybe take a closer look in the blink documentation or check your python version.

Sign up to request clarification or add additional context in comments.

3 Comments

This still doesn't answer why the two print() outputs 4105 tho?
I've worked out it only works with python3, so I need to work out how to set that as default...
I am glad that i could help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.