New
#1011
Making a little headway with my LED Shim. I have it changing color based on the measured temp. I'm changing all 28 LED's though, need to figure out how to just change a set number / group of them. I could replace my current 4 10mm LED's with it and get the same functionality. I'm going to wait though as its a lot easier to tinker with hooked up to my bread board Pi. Its been a bit of a struggle but there's a light at the end of the tunnel now. =) Oh wait, was that a train whistle I just heard?
My rover is still fighting me. Stalling on one side only? it’s not the motor, with no tracks on they both spin at the same speed and both require the same pressure to stall them. Also, reversing the motor connections on the explorer pHat left to right (swapping the motor 1 and motor 2) makes no difference. It’s only with the track on that it stalls?
Checked and double checked its 85 mm between wheel centers. Also checked and double checked the alignment (center line) of both sides to be sure the track is straight? and that the idler is straight. Tracks aren’t rubbing on anything. I’m at a lose as to why this won’t work. With the track off the idler spins nice a free. Put the track back on a very light finger pressure stalls that side?
Wheels and idler are on as per the pictures with the washer in the correct place. Putting it away for now. Maybe latter on I'll back the car over it and be done with it. Only half kidding.
Made good progress with my LED Shim though. Phil from Pimoroni came through with some code to try. I have my scales or background colors, or what ever you want to call them the way I want now. Just have to set my marker for the current temp. That’s going to require some math I think. Might do that another day. I'll post some of the code when I get it refined a little more. Its still a proof of concept at the moment. Really happy with the progress I made today though. =)
Working on my LED Shim python code, not going to post it until I test it though. I just coded it up on my PC, haven't actually ran it on the Pi though. Stuck inside today as its raining, and no room to get that Pi out until my wife gets up. Only free space is on my dresser in the bedroom. She a late riser. The math I had to do was interesting. I hope it works.
The LED shim LEDs are numbered 0 - 1 - 2 - 3 - 4 etc. Left to right. I have mine virtual though and the first LED is on the top. So mine goes.
0
1
2
3
4
etc.
My temperature scale goes the other direction though 0c is near the bottom and 27c is up top. So as my temp rises my marker goes up. Which means the number corresponding to the LED "M" goes down. Confused yet? I was getting negative values that I had to multiply by -1 to make positive. Assuming it works, lol. I have three scales for different temp ranges, one for below 0c, one for 0c to 28c and one for above 28c. That's how it is at the moment. That may change with use. I only have 28 LEDs to work with and wanted 1 degree c between LED's. Time for a break I think. Necks getting sore.
Here is my test code. Keep in mind that my LED shim is vertical with LED 0 at the top and 27 at the bottom. And my marker goes up as temp increases. It made for some interesting math to get it to track in the right direction.
For testing I set my temp at -30 and had it increment by 1 every second and a half.
Below -27 there is no marker, just all blue LED’s. once it hits -27 it appears at the bottom and moves up until you hit 0c, the top most LED. Then the scale shifts and it counts up from 1c to 28c. If it goes over 28c it turns orange and counts up from 28. I may change the last scale to be 25c at the bottom. It all works with no exception errors so I’m happy for now.
Code:#!/usr/bin/python #!/usr/bin/env python import time import ledshim import Adafruit_BMP.BMP085 as BMP085 sensor = BMP085.BMP085() def set_multiple_pixels(indexes, r, g, b): for index in indexes: ledshim.set_pixel(index, r, g, b) ledshim.set_clear_on_exit() t = -30 while True: #t= sensor.read_temperature() #t= round(t) #print(t) if t <= 0 and t >= -27: ledshim.set_all(0, 0, 255) #Blue M = (t * (-1)) ledshim.set_pixel(M, 255, 255, 255) # B B B B B B B B B B B B B B B B B B B B B B B B B B B B elif t > 0 and t <= 28: # Main set_multiple_pixels(range(0,3), 255, 0, 0) #Red set_multiple_pixels(range(3,16), 0, 255, 0) #Green set_multiple_pixels(range(16,28), 255, 255, 0) #Yellow M = (28 - t) ledshim.set_pixel(M, 255, 255, 255) # R R R G G G G G G G G G G G G G Y Y Y Y Y Y Y Y Y Y Y Y elif t > 28: # Realy Hot ledshim.set_all(255, 165, 0) #Orange M = (t - 56) * (-1) ledshim.set_pixel(M, 255, 255, 255) # O O O O O O O O O O O O O O O O O O O O O O O O O O O O else: ledshim.set_all(0, 0, 255) # B B B B B B B B B B B B B B B B B B B B B B B B B B B B ledshim.show() time.sleep(1.5) t = t + 1
Some time tomorrow I'll put it in my portable weather clock. I have a little rewiring / soldering to do to do that. I just finished editing my original python file adding the new code and taking out the old code for the 10mm LED's. Neck and shoulders are too sore to tackle the rewiring now. I may add a dim function for the LED Shim too, have to see how bright it is behind the diffusor at night in dark conditions. Happy enough to just get it working at the moment.