Menu

How to Program Arduino UNO R3 With GCBASIC

2015-01-28
2023-06-30
<< < 1 2 3 4 > >> (Page 2 of 4)
  • Anobium

    Anobium - 2022-09-12

    But, I would point out.. that the LGT328p is twice as fast, and a lot more robust that the UNO for your type of project with high current ports.

    I have some for sale - ping me if you want to buy one.

     
    • Keith

      Keith - 2022-09-16

      I'll take a pass on this one Evann. I think the UNO is going to do what I'm looking for as I only need about a kHz pulse train, an EN (Enable) and a DIR control for the Stepper Driver Modules.
      Has anyone written a port allocation table for this beast? (UNO) I have a Muppet sheet with the location of the pin-outs. Do I take it that PB0 to to PB5 are B0 to B5 etc
      Do I treat them the same Microchip Ports?

      Hope I haven't bitten off more than I can chew AGAIN !

       
      • Anobium

        Anobium - 2022-09-17

        Look at the Help and the demos.

        #include <UNO_mega328p.h >
        

        This include then provides: The ADC setting, the Ports and USART basic setup.

        'Chip settings
        #CHIP MEGA328P, 16
        
        'STARTUP ROUTINE
        #STARTUP INITUNO, 90
        
        #OPTION USERINCLUDE
        
        'A/D speed
        'Need to slow down due to high clock speed
        #define ADSpeed LowSpeed
        
        'Analog inputs
        'Analog 0 to 5 = AN0 to AN5 in GCBASIC
        #define ANALOG_0 PORTC.0
        #define ANALOG_1 PORTC.1
        #define ANALOG_2 PORTC.2
        #define ANALOG_3 PORTC.3
        #define ANALOG_4 PORTC.4
        #define ANALOG_5 PORTC.5
        #define RESET portc.6
        
        'Digital pins
        #define DIGITAL_0 PORTD.0
        #define DIGITAL_1 PORTD.1
        #define DIGITAL_2 PORTD.2
        #define DIGITAL_3 PORTD.3
        #define DIGITAL_4 PORTD.4
        
        #define DIGITAL_5 PORTD.5
        #define DIGITAL_6 PORTD.6
        #define DIGITAL_7 PORTD.7
        #define DIGITAL_8 PORTB.0
        
        #define DIGITAL_9 PORTB.1
        #define DIGITAL_10 PORTB.2
        #define DIGITAL_11 PORTB.3
        #define DIGITAL_12 PORTB.4
        #define DIGITAL_13 PORTB.5
        
        'On-board devices
        #define LED PORTB.5
        #define BUTTON PORTC.6
        
        '''@hide
        Sub InitUno
          'Set UART pin directions
          Dir PORTD.0 In
          Dir PORTD.1 Out
        End Sub
        
         

        Last edit: Anobium 2022-09-17
      • stan cartwright

        stan cartwright - 2022-09-17

        A uno and gcb is just one device to learn not like pics. It should do what you want with no setup like pics and is good spec and speed. How you name the pins is if you use

        #include <UNO_mega328p.h >
        

        or you will need to use port names ie port b.1

         
      • stan cartwright

        stan cartwright - 2022-09-17

        I do not know if you used a uno with gcb but it will need selecting in programmer preferences by dragging arduino uno to the top.
        Edit to select usb com port. Com port is shown in win devices.

         

        Last edit: stan cartwright 2022-09-17
      • stan cartwright

        stan cartwright - 2022-09-17

        Do stepper motors need KHz?
        I use 50Hz.

         
  • stan cartwright

    stan cartwright - 2022-09-12

    Spot the difference competition

     
    • Anobium

      Anobium - 2022-09-12

      One is very fast, one is easy to use..

       
  • stan cartwright

    stan cartwright - 2022-09-12

    Spot the difference competition

     
  • stan cartwright

    stan cartwright - 2022-09-12

    The LGT328p is also 3.3V logic so ideal to use a ili9341 and the wiring is enough but without logic level converters, like mega328.
    The speed difference is noticeable displaying graphics.

     
    • Anobium

      Anobium - 2022-09-12

      The LGT328p is a very nice chip. As you say.. the GLCD proves the speed difference. For the same GLCD library function(s) you can see the speed difference between a Mega328p and the LGtT328p.
      ..

       
  • stan cartwright

    stan cartwright - 2022-09-12

    It was mega328p for uno and nano that sold me to gcb years ago. So easy usb plug 'n' play.
    The lgt328 support was great. It has better a-d but not tried.
    ott for most stuff but good for the "illusion" of moving graphics.
    Using a parallel display would be very fast if enough pins.
    I just found a 2560 which I think is supported., a uno with more pins...

    Just tried gcstudio. it took 3 minutes to update. It took ages to find programmer preferences as the interface changes like the weather.

     

    Last edit: stan cartwright 2022-09-12
  • stan cartwright

    stan cartwright - 2022-09-12

    Spot the difference competition 2

     
    • Anobium

      Anobium - 2022-09-13

      Left is an LGT and right is Pi

       
  • stan cartwright

    stan cartwright - 2022-09-13

    You win the prize. They say it is the thought that counts... so I thought of a nice prize :)
    and the rpi is upside down from normal!

     
    • Anobium

      Anobium - 2022-09-13

      Trying to trick me!!

       
  • Keith

    Keith - 2022-09-18

    First Hurdle. After spending nearly ten hours trying to get these five buttons to work, on the Keypad Shield I'm shouting for help.

    Using some code I found here by Mike Motte

    DIM BTTNPUSH AS Word

    ; MAIN PROGRAM
    WAIT 2 S
    set LCDBacklight on
    PRINT " PRESS A BUTTON"
    WAIT 2 S
    Do Forever
    cls
    BTTNPUSH = READAD10(AN0)
    Print BTTNPUSH
    Select Case BTTNPUSH
    Case < 50
    CLS
    PRINT "RIGHT"
    Case > 60 & BTTNPUSH < 200
    CLS
    PRINT "UP"
    Case > 200 & BTTNPUSH < 400
    CLS
    PRINT "DOWN"
    Case > 400 & BTTNPUSH < 600
    CLS
    PRINT "LEFT"
    Case > 600 & BTTNPUSH < 800
    CLS
    PRINT "SELECT"
    End Select
    wait 2 s
    LOOP

    I can reciprocate this on my Uno. I press Left Button and Left is written in the display etc.

    I also have five variables mapped up.

    Dim ButtonLeft as Byte
    Dim ButtonRight as Byte
    Dim ButtonUp as Byte
    Dim ButtonDown as Byte
    Dim ButtonSelect as Byte

    The problem that I'm struggling with is how to convert what I have in the case conditions into Logical 1 or 0 in my variables i.e. ButtonLeft = 1

     
    • stan cartwright

      stan cartwright - 2022-09-18
      #define ButtonLeft PORTB.1
      #define ButtonRight PORTB.2
      #define ButtonUp PORTB.3
      #define ButtonDown PORTB.4
      #define ButtonSelect PORTB.5
      
      if ButtonLeft on then ;left button pressed
      
       
      • stan cartwright

        stan cartwright - 2022-09-18

        Do Forever? Do loop
        BTTNPUSH = READAD10(AN0) . I do not under stand how this represents a button pressed.

        PRINT " PRESS A BUTTON"
        WAIT 2 S
        Do Forever
        cls
        BTTNPUSH = READAD10(AN0)
        Print BTTNPUSH
        Select Case BTTNPUSH
        Case < 50
        CLS
        PRINT "RIGHT"
        Case > 60 & BTTNPUSH < 200
        CLS
        PRINT "UP"
        Case > 200 & BTTNPUSH < 400
        CLS
        PRINT "DOWN"
        Case > 400 & BTTNPUSH < 600
        CLS
        PRINT "LEFT"
        Case > 600 & BTTNPUSH < 800
        CLS
        PRINT "SELECT"
        End Select
        wait 2 s
        LOOP
        
         
        • Anobium

          Anobium - 2022-09-18

          Stan. We need to confirm the board type. Is it a per the folder in the demos? or, not?

          It the demo folder is the PCB. This boars uses resistors to set the ADC values. But, the short in the cheapo boards means bad things happen.

           
    • Anobium

      Anobium - 2022-09-18

      @Keith

      There is a demo for the keyboard shield.

      Does you board look like this?

      The demo for the board above is in your C:\GCstudio\GreatCowBASIC\demos\LCD_Solutions\Four_Wire_LCD_Solutions folder - YOU MUST look at the C:\GCstudio\GreatCowBASIC\demos\LCD_Solutions\Four_Wire_LCD_Solutions\Arduino_LCDShield folder as the cheapo boards from China have a short and you will damage your UNO. The folder shows the fix.

      Hope this helps.

       

      Last edit: Anobium 2022-09-18
      • Keith

        Keith - 2022-09-23

        I have seen a schematic somewhere which shows the Diode (D10) and where to to cut the print. - I can't find it !

        I was going to modify these two over the weekend.

         
        • Anobium

          Anobium - 2022-09-24

          The diagrams and info are in the Help folders.

           
  • Keith

    Keith - 2022-09-18

    Thank you Evann, I read through this a while back and checked the Display Shields I have, I'm nearly sure I'm okay.

    @ Stan. I am already using all my ports, as I/O Lines but I thought the Keypad buttons were all attached in series to AD10(AN0) and taken in as a voltage ?? I want to use the five keypad buttons.

     
<< < 1 2 3 4 > >> (Page 2 of 4)

Log in to post a comment.