Make: "It's New to You" Bit

Thanks for sharing your circuits, @Kadin907 :smile: Would you like to make the oscillator work as a bit? If you post a drawing of the circuit, we can start from there.

1 Like

I hope some folks are still participating in the #InventAnything hardware page, I started late, but thank you to @vanessa and @chloeatplay for still inviting me to participate. So anyway, here goes with the hardware assignment as I understand it. I thought a lot about what would be my favorite bit, but almost right away decided to pick what I thought might be the most challenging bit to recreate, the new number+ bit. I was not really excited about the number bits right away, but realized quickly that it is the essential “tuning bit” for cloud control and threshold setup, among many other input to output setups. I wanted a challenge for this first assignment, and I got it. I really had to think outside the “bit”.
I imposed a few requirements of my own, first being that I would recreate the bit with parts I had on hand. Second, I did not want to “cheat” and look at any published schematics available. I was able to put the hardware together relatively quickly, it consists of an ATmel ATTiny84, two 74HC595 shift registers running two seven segment displays(allows for three outputs only from tiny84), and I used a 10K pot to for a voltage divider instead of a four position switch(don’t have one of those floating around, do you?). The function of the switch/divider can be dealt with easily in the code. Any other parts you see in the in progress pics below were used for tuning before connecting to any 'Bits. I will post more on

the coding required and problems there soon. The pictures show the breadboard prototype in the volts mode, and counting up and down.

3 Likes

#InventAything, “It’s New to You” Hardware, Part 2.
Here is the basic progression of writing the code for this module. First step was to define the characters for the shift registers, basically taking the binary numbers and converting them to hexadecimal, to prove I could count thru the display.
//This is the hex value of each number stored in an array by index num
byte digitOne[10]= {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98};
byte digitTwo[10]= {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98};

Encountered my first obstacle, how to convert a decimal number to ten’s and one’s(divide by ten, return the modulo).
case 0:
value = analogRead(bitInput);
variable = map(value, 0, 1023, 0, 99); // map bit input to % values
pwm = map(value, 0, 1023, 0, 255); // provide output values for bit output
result1 = variable / 10; // divide by ten for the first digit
result2 = variable % 10; // use the modulo to provide the remainder(the second digit)
a = result1;
b = result2;

As stated, wanted to use only parts on hand, using a 10K pot, map values to four modes.
Mode = analogRead(modeSwitch);
Range = map(Mode, 0, 1023, 0, 3);

The rest of the code is easy to piece together, map values for percentage, volts, and up from “0”, down to “99”
switch (Range) {

case 0:
  value = analogRead(bitInput);
  variable = map(value, 0, 1023, 0, 99);  // map bit input to % values
  pwm = map(value, 0, 1023, 0, 255);  // provide output values for bit output
  result1 = variable / 10;  // divide by ten for the first digit
  result2 = variable % 10;  // use the modulo to provide the remainder(the second digit)
  a = result1;
  b = result2;


    digitalWrite(LATCH, LOW);
    shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
    shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
    digitalWrite(LATCH, HIGH);
    delay(10);
    analogWrite(Output, pwm);  // set output to mapped value
    break;
    
case 1: 
  value = analogRead(bitInput);
  variable = map(value, 0, 1023, 0, 50); // map values to voltage readout
  pwm = map(value, 0, 1023, 0, 255);  // provide output values for bit output
  result1 = variable / 10;
  result2 = variable % 10;
  a = result1;
  b = result2;
  
    digitalWrite(DP, HIGH);  // decimal point for volts reading
    digitalWrite(LATCH, LOW);
    shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
    shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
    digitalWrite(LATCH, HIGH);
    delay(10);
    digitalWrite(DP, LOW);
    analogWrite(Output, pwm);  // set output to mapped value
    break;
    
case 2:
  buttonState = digitalRead(bitInput);
  if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
  buttonPushCounter++;
} 
  }
  lastButtonState = buttonState;
  
      variable = constrain(buttonPushCounter, 0, 99); // map values to count up
      pwm = map(variable, 0, 99, 0, 255);
      result1 = variable / 10;
      result2 = variable % 10;
      a = result1;
      b = result2;
      
      resetState = analogRead(reset);
       if(resetState >= 511)  // if reset detected, reset values to zero
        {
         a = 0;
         b = 0;
         
          digitalWrite(LATCH, LOW);
          shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
          shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
          digitalWrite(LATCH, HIGH);
          delay(10);
          buttonPushCounter = 00;  // when reset, set global variables to "00"
          break;
        } 
        
          digitalWrite(LATCH, LOW);
          shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
          shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
          digitalWrite(LATCH, HIGH);
          delay(10);
          analogWrite(Output, pwm);  // set output to mapped value
    break;
    
case 3:
  buttonState = digitalRead(bitInput);
  if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
  buttonPushCounter--;
} 
  }
  lastButtonState = buttonState;
  
      variable = constrain(buttonPushCounter, 0, 99);  // map values to count down
      pwm = map(variable, 0, 99, 0, 255);
      result1 = variable / 10;
      result2 = variable % 10;
      a = result1;
      b = result2;
      
      resetState = analogRead(reset);
       if(resetState >= 511)  // if reset detected, set values to "99"
        {
         a = 9;
         b = 9;
          digitalWrite(LATCH, LOW);
          shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
          shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
          digitalWrite(LATCH, HIGH);
          delay(10);
          buttonPushCounter = 99;  // when reset, set global variable to"99"
          break;
        }           
          digitalWrite(LATCH, LOW);
          shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[b]); // shiftout digitTwo
          shiftOut(DATA, CLK, MSBFIRST, ~digitOne[a]); // shiftout digitOne
          digitalWrite(LATCH, HIGH);
          delay(10);
          analogWrite(Output, pwm);  // set output to mapped value
    break;   
}

Encountered second obstacle, in modes three and four, when counting up and down, pwm values continue to roll over. Fixed by mapping the constrained values only.
variable = constrain(buttonPushCounter, 0, 99); // map values to count up
pwm = map(variable, 0, 99, 0, 255);

Only problem that remains is the output filter, cannot seem to match values exactly, many variations tried, but main problem is when hooked to littleBits dimmer and number bits, inputs of 4.4 V to 4.5 V end up registering as solid 5 V.
More work to be done on a low-pass/high-pass filter to even out pwm from ATTiny, currently have a hybrid of the the two that is “close”, but no cigar.

Sorry for the messed up display on the coding, didn’t know exactly how to paste in. Tried to upload .ino, unsuccessful.

Hopefully this gets anyone the .ino

Looking good, @StuckInSynth! I appreciate that you are building this without referring to the littleBits schematic. :slight_smile: You could probably combine the functionality of the Number+ with the Threshold in one bit.

1 Like

So sorry to not complete this posting/project in a timely fashion. I’m having quite an issue designing a workable PWM output filter (R/C based, Sallen-Key, or otherwise). All designs thus far result in a scaling issue on the top or bottom end of the 5 volt range, hence the displayed input does not exactly match the voltage out. May be looking around for some help on this one to get it completed. Excellent idea @JackANDJude on integrating the threshold into this module, would be easy if I could get the output right, I do plan on building this and it would make a cool custom bit.

1 Like

I actually made a number bit. I remember becoming frustrated at it not being quite right. I kept fudging the mapping to correct for differences between the usb power vs the battery power. I think one of the powers would only get to 4.8 when the other would get to 5.0.

I put it away for a day when they released the code. Then they released the code, and I didn’t understand it. HA! :smile: It’s weird but for a long time I felt like I needed to make a bit first before I would allow myself to buy the pre-engineered version…

Anyhoo… :smile:
@Philip_Verbeek, maybe you have some insight into the issue @StuckInSynth is experiencing?

Nice project @StuckInSynth @JackANDJude !

To “convert” a PWM-signal to an analog voltage for my NFC-bit I only used a low pass filter:

See also this link: http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/

I used R = 3.9K and C = 0.1uF. This did the trick for me:)

Let me know if it does for you too.

PS: This is low pass filter littleBits uses on the arduino-Bit: https://github.com/littlebitselectronics/eagle-files/blob/master/WIRE/LB_BIT_w6_ARDUINO/LB_BIT_w6_ARDUINO-v03(4-5)/LB_BIT_w6_ARDUINO-v03(4-5)OHW.pdf

This thread just keeps getting funner and funner! The number bit is just a bit much for me, but a bargraph seems just right up my alley! So here is my own ‘new-to-me’ bit, the bargraph+ …

and a closeup:

It’s got a ten segment bargraph in a DIP package, and special effects, powered by an on-board Arduino Micro. The effects include normal mode, single bar mode (each individual LED can be controlled with the input voltage), and cylon mode. Cylon mode actually has two modes of it’s own, Knight Rider, and Warp Engine. Here are my special bargraph effects in action:

If I get some bitsnaps, I’ll make this into a real bit on a perf board.

4 Likes

@chris101 What an awesome mashup of the number and bargraph! I like the modes. :vertical_traffic_light: Bonus points for your wires and resistors being all snug as a bug in a rug!

3 Likes

Thanks Jude - I look at breadboards like little canvases. Not only should they function, they should also look good! :wink:

But this started out looking all prototypy. In fact if you have 3D glasses ( ), you can appreciate just how messy my project began:

1 Like

Hilarious, @chris101! I wish I had 3D glasses. :sunglasses: Before I forget, I hope we’ll see you at the next community call! Please bring your Bargraph Bit and your Purple People Counter, @chris101. :smile:

@StuckInSynth, I also hope you can join us? Bring your most recent breadboarded bits so you can show off to others in real time! :smile:

@Kadin907 :arrow_left: You still with us? We’d love to hear from you. :smile:

Thanks as always @JackANDJude!

If I can squeeze a visit in, I will. Unfortunately noon Eastern translates to 10 in the morning out here in the West. And on Wednesday 10am means it’s time for organic chemistry. The semester will be over in a few weeks though, I’ll try to keep 10am on Wednesday blocked out, so I can participate in these - I’d love to see y’all in real-ish life!

1 Like

I moved 10 posts to an existing topic: Programming ATtiny chips

I moved 6 posts to a new topic: Programming ATtiny chips

Hope this is the right place to post. We created a range sensor module and submitted it to the bitlab. I’m sure it could be improved. But I’m not an electrical engineer and this was my son and mines first bit: https://github.com/shaiss/LittleBitsUltrasonicRangeSensor?files=1


2 Likes

Hey, friends! Here’s a video from William (WCR). He commented on my Instructables with a video of his “SimpleBits, Ebits” Check it out! :smile: I invited him to come here and say hi. :smile:
@StuckInSynth @Philip_Verbeek @joey, @kadin907, @matthiasmwolf, @ludvikherrera @shaiss, @alexpikkert, @chris101

3 Likes

This is interesting because there are only 2 connections instead of 3 (lately, since getting into twi, I’ve been wanting 4 connectors.) This is much simpler than using 3 connectors from the circuit design standpoint, however it seems it would be a problem when designing digital devices, such as arduino or number bits.

I hope William Ribeiro does join us - I’d love to hear how he mixes his power and signals into a single line. I’ve read of, but never used something called a one wire interface.

ps, I want to see more of his robot work as well!

Hi,
In your opinion, the LittleBits is more focused on teaching or entertainment?
If be teaching, would be teaching more physics or electronics?
thank you :smiley: