​ ​ ​ ​ Please point me to some step by step basics to code the PICAXE using Blockly. - Page 19
Page 19 of 21 FirstFirst ... 9 17 18 19 20 21 LastLast
Results 181 to 190 of 206

Thread: Please point me to some step by step basics to code the PICAXE using Blockly.

  1. #181
    Senior Member
    Join Date
    Jan 1970
    Location
    Colorado USA
    Posts
    3,212

    Default

    Put negative LED to V- and + LED lead to output pin through 220 ohm resistor. Use HIGH and LOW commands to turn LED on/off. See Manual 3 for interfacing details.

  2. #182
    Member
    Join Date
    May 2018
    Location
    Ft. Myers FL
    Posts
    91

    Default

    Right i understand that but in this case we have 16 LEDS connected in an array going to 8 pins. To light an LED we must tell one pin to go high and another pin to go low. Must that be two separate commands?

  3. #183
    Senior Member
    Join Date
    Jan 1970
    Location
    Colorado USA
    Posts
    3,212

    Default

    I don't know how you have them connected - assuming only one being on at a time - likely you can turn on on one with HIGH, other with LOW and both off by changing pin to an input... pseudo tri-state pin...

  4. #184
    Senior Member
    Join Date
    Feb 2010
    Location
    Don't Mess With My Texas!
    Posts
    2,566
    Blog Entries
    7

    Default

    Gramps, you are going to create a "translation table" perhaps using a spreadsheet or simply use a notepad. This table contains musical notes for the program and output bits that produce the correct combination of output pins to make each note's LED light up.

    List your musical notes (assuming LEDs represent these notes) on lines from top to bottom to make sure you are representing all notes that you want.

    Next to each note you could simply list an 8-bit number that represents the note in your program hopefully represented in a SYMBOL statement e.g. "SYMBOL Asharp = 12". This is your index into the following output bits for the output pins.

    The next column is where the magic happens (read that tedious programming ). Decide which bit in an 8-bit byte will represent a particular output pin. This is the "translating" part. For each note by using binary representation (show zeros and ones), determine which output pin(s) have to be HIGH and/or LOW to make the LED for that note light up.

    By doing this translating (from inputs to outputs) you have created a table that makes programming much easier. Your program won't change if you move your LEDs around or add LEDs or etc. You just change your output pin translation! I'll tell you who taught me that ... HIPPY!

    With this information, you can create several ways to to make it work depending on speed requirements, but one way is using a LOOKUP statement. Other ways include SELECT/CASE, or a bunch of IF/THEN statements. I'm sure there are other ways.
    - Tex
    __________________________________________________ _______________________
    These words are my opinion, WYLION. Any resemblance to truth or fiction is accidental at best.
    "Truth lies dormant in our future history." ― Tex Clodhopper LXVI
    "Confidence is ignorance. If you're feeling cocky, it's because there's something you don't know." ― Eoin Colfer, Artemis Fowl

  5. #185
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,373

    Default

    Quote Originally Posted by Gramps View Post
    Right i understand that but in this case we have 16 LEDS connected in an array going to 8 pins. To light an LED we must tell one pin to go high and another pin to go low. Must that be two separate commands?
    In general it will require two separate commands, though if one of the pins is already at the level required you would only have to alter the pin which isn't.

    That is more likely to be the case when multiplexing a matrix to control more than one LED at a time. A particular set of cathodes may be set low and then you would only need to cycle through setting anodes high. For setting one LED and leaving it set two commands would be required for that.

  6. #186
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,832

    Default

    Sorry, Gramps, I didn't see your post from 7/10.

    See post 44 (and 47) for the 28x2 code and translation table I used for the matrix, in particular:

    The possible hammered dulcimer notes are shown in the comment line below, and the encoding for the LEDs in the line following:
    Code:
    ' G3,-G#3,A3,-Bb3,B3,C4, C#4,D4,-Eb4, E4,F4, F#4,G4, G#4, A4,Bb4,B4, C5, C#5, D5,-Eb5,E5, F5,F#5, G5,-G#5,A5,-Bb5,B5, C6,-C#6,D6
    '$00,$FF,$01,$FF,$02,$03,$10,$C0,$FF,$C1,$11,$12,$C2,$13,$C3,$20,$C4,$C5,$21,$C6,$FF,$C7,$22,$23,$C8,$FF,$30,$FF,$31,$32,$FF,$33
    In the encoding, "$FF" means not available (as does "-" in the first line), "$C0-$C8" means pins C.0 through C.7 and A.0 (for the 9 notes which occur more than once), and other values indicate which pins in portB are activated for the appropriate LED in the 4x4 matrix. Each matrix-indicating byte value is made up of 2 nybbles, each of which may have a value between 0 and 3. The high nybble I've assigned to the anode (positive) side of the led, and will bring high B.0, B.1, B.2, or B.3. The low nybble will have 4 added to it so that it refers to B.4, B.5, B.6, and B.7 (one of which will be brought low). The non-selected high nybble and low nybble pins are tri-stated (made inputs)

  7. #187
    Member
    Join Date
    May 2018
    Location
    Ft. Myers FL
    Posts
    91

    Default

    Thank you again for the detailed instructions!
    We still need to purchase an LCD screen.
    Which one should we get?

  8. #188
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,832

    Default

    Quote Originally Posted by Gramps View Post
    We still need to purchase an LCD screen. Which one should we get?
    It's hard to say. As far as I can tell, all the "serial" LCDs and OLEDs on the first few pages of Amazon (which you might get quickly), or ebay are actually I2C (TWI) two-wire modules, and I don't think you have the pins available, especially the default port B pins (though you might be able to bit-bang it on other pins (which you still don't have available)).

    Rev-Ed's true serial OLED is here: http://www.picaxestore.com/index.php...s/axe133y.html

    That might be your best bet, though I would still consider a 40X2 on a breadboard so you would have plenty of free pins. Then you could use the inexpensive I2C or SPI modules.

  9. #189
    Member
    Join Date
    May 2018
    Location
    Ft. Myers FL
    Posts
    91

    Default

    Yes there are not enough pins on a 28x2 to do this project. So we are scaling it back and going to use 8 notes to get started, D4, E4, F#4, G4, A4, B4, C5 and D5.
    Using a magnifying glass I think I have found the nine correct pins and the ground on the education board.
    this really looks like it would be easier to do if the chip was directly plugged into the project workspace rather than trying to use the education board.
    After we get that working, we'll get a 40 pin chip.
    Last edited by Gramps; 13-07-2018 at 21:07.

  10. #190
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,832

    Default

    Quote Originally Posted by Gramps View Post
    ... we'll get a 40 pin chip.
    Alternatively, you could use an i2c i/0 expander like the MCP17008 (for 8 pins) or MCP17016 (for 16 pins). That would take away C.3 and C.4--hi2c scl and hi2c sda--but would enable you to use an i2c display without taking up additional pins. The 40X2 would make for cleaner code, though.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •