Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today!
Official Members also get to use the forum ad-free - so kit up and join us!

 Help needed for Gauntlet Display controlled by Arduino

  • 6 Replies
  • 2492 Views

Bar'uun Strieg


    *
  • *
  • *
  • 750
  • Vurel tome, draar solus
  • Awards 15+ clan level invasions
First..........Writing code is NOT my strong suit and I need some help.

Project is to have a small 1.8" TFT display controlled by an Arduino mounted on my left gauntlet.  I found some Arduino Code that will cycle through images on the display (think electronic photo frame), but I really want to add a button that will cycle to the next image when pressed, and ultimately have a second button as a "back to previous image" function.

I started with the project from this link:
https://learn.adafruit.com/1-8-tft-display/overview?view=all

I found this example which basically turns it into a digital photo frame.
http://blog.simtronyx.de/en/an-image-slideshow-with-an-arduino-and-a-tft-display-with-a-sd-card-module/

If anybody know Arduino code and can help modify the sketch to use buttons as forward and back functions for the display, it would be greatly appreciated.

Logged
Cabur Akaata #104, S.P.A.R.K. #22, Grey Brigade #48, M.L.C.S. #36, M.V.S. #55, Mando Riders #40, O.O.O.P.S. #23

Kuu


    *
  • *
  • *
  • *
  • *
  • *
  • 3345
  • As Haran Mhi Nu'Lise' - Ja'haili' Ni
  • Awards 15+ clan level invasions Order of the Ori'Ramikad Poster Boy - Official Member appears in costume in the most photos Award for 10 official invasions. Hard Contact - Clan with the most recorded invasions
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #1 on: Apr 04, 2017, 01:18 PM »

Logged

| aka "Matt R." | Helpful Stuff |Facebook | VRCA #053 | M.V.S. #10 | B.E.A.R.D.S. #77 | S.P.A.R.C.K. #2 | OM: Sept. 20, 2014

Bar'uun Strieg


    *
  • *
  • *
  • 750
  • Vurel tome, draar solus
  • Awards 15+ clan level invasions
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #2 on: Apr 04, 2017, 01:34 PM »
You should be able to leverage my ammo counter.

http://mandalorianmercs.org/forum/index.php?topic=91886.msg1348087#msg1348087

Thanks Kuu, but I really don't know the code well enough to figure my problem out.....I've been slamming my head against a wall trying to get it to work, but haven't had any luck.....just frustration.

Logged
Cabur Akaata #104, S.P.A.R.K. #22, Grey Brigade #48, M.L.C.S. #36, M.V.S. #55, Mando Riders #40, O.O.O.P.S. #23

Kuu


    *
  • *
  • *
  • *
  • *
  • *
  • 3345
  • As Haran Mhi Nu'Lise' - Ja'haili' Ni
  • Awards 15+ clan level invasions Order of the Ori'Ramikad Poster Boy - Official Member appears in costume in the most photos Award for 10 official invasions. Hard Contact - Clan with the most recorded invasions
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #3 on: Apr 05, 2017, 12:19 PM »
I'd need to get those parts to test the code but conceptually:

So in my code I setup 2 buttons
  buttonPin
  buttonReloadPin
and
  buttonState
  buttonReloadState

Then in the setup() I tell the code those buttons exist
  pinMode(buttonPin,INPUT);
  pinMode(buttonReloadPin,INPUT);

Then in the loop() I read the buttons   
  buttonState = digitalRead(buttonPin);   
  buttonReloadState = digitalRead(buttonReloadPin);

and if they're pressed (buttonReloadState==0 and buttonState==0) I do stuff.

Basically you want to take that example code and stick it inside a button press

  if (buttonState==0)
  {
   Do stuff to advance the picture
  }

  if (buttonReloadState==0)
  {
  Do stuff to go back a picture or restart the process
  }

And you'll want to take out the delay stuff since you want the buttons to control it.

Logged

| aka "Matt R." | Helpful Stuff |Facebook | VRCA #053 | M.V.S. #10 | B.E.A.R.D.S. #77 | S.P.A.R.C.K. #2 | OM: Sept. 20, 2014

Bar'uun Strieg


    *
  • *
  • *
  • 750
  • Vurel tome, draar solus
  • Awards 15+ clan level invasions
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #4 on: Apr 05, 2017, 12:46 PM »
Thanks Kuu.  One problem I ran into last night was when I defined
const int buttonPin = 7;

then tried to use
pinMode(buttonPin, INPUT);

The code wouldn't compile and errored on the pinMode line.....I wish I knew code better.  This is frustrating the crap out of me.

Logged
Cabur Akaata #104, S.P.A.R.K. #22, Grey Brigade #48, M.L.C.S. #36, M.V.S. #55, Mando Riders #40, O.O.O.P.S. #23

LightningLion


    *
  • 159
  • Electronics are my thing
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #5 on: Apr 22, 2017, 10:13 AM »
In the ADAFruit code add this variables, pinModes in the setup and replace loop with this one. DON'T delete bmpDraw function.
If this doesn't work let me know which error you receive.

It would work as long as your images are named:
image_X.bmp (for 1 digit)
image_XY.bmp (for 2 digits).

It won't work if first iamges are called image_02.bmp for example.

Code: [Select]

int bmpcount = 1;
const int bmpmaxnumber = 99; //highest number of bitmaps on your SD.
String bmpname = "image_01.bmp";
const byte prevButton = 3;
const byte nextButton = 4;
int incomingByte = 0;   // for incoming serial data

void setup(){
   
    pinMode(prevButton, INPUT);
    pinMode(nextButton, INPUT);
    bmpDraw("image_1.bmp", 0, 0);

}

void loop(){ 
 
    if ((prevButton == LOW) && (nextButton == HIGH)) {
    //let's go one pic forward
      if (bmpcount < bmpmaxnumber){
        bmpcount++;
      } else {
        bmpcount = bmpmaxnumber;
      }
     
      bmpname = "image_" + String(bmpcount) + ".bmp";
      bmpDraw(bmpname, 0, 0);
     
   
   
    }
   
    if ((prevButton == HIGH) && (nextButton == LOW)) {
    //let's go one pic back
   
      if (bmpcount > 1){
        bmpcount--;
      } else {
        bmpcount = 1;
      }
     
      bmpname = "image_" + String(bmpcount) + ".bmp";
      bmpDraw(bmpname, 0, 0);
   
    }

}

Logged
Lion's electronics corner

Rionu Custom Electronics for your Mandos
--->> Sales thread

WIPs: Nite Owl helmet. Modern era helmet.

Mundo Airsofter - Airsoft news & reviews

Bar'uun Strieg


    *
  • *
  • *
  • 750
  • Vurel tome, draar solus
  • Awards 15+ clan level invasions
Re: Help needed for Gauntlet Display controlled by Arduino
« Reply #6 on: Apr 27, 2017, 03:02 PM »
In the ADAFruit code add this variables, pinModes in the setup and replace loop with this one. DON'T delete bmpDraw function.
If this doesn't work let me know which error you receive.

It would work as long as your images are named:
image_X.bmp (for 1 digit)
image_XY.bmp (for 2 digits).

It won't work if first iamges are called image_02.bmp for example.

Code: [Select]

int bmpcount = 1;
const int bmpmaxnumber = 99; //highest number of bitmaps on your SD.
String bmpname = "image_01.bmp";
const byte prevButton = 3;
const byte nextButton = 4;
int incomingByte = 0;   // for incoming serial data

void setup(){
   
    pinMode(prevButton, INPUT);
    pinMode(nextButton, INPUT);
    bmpDraw("image_1.bmp", 0, 0);

}

void loop(){ 
 
    if ((prevButton == LOW) && (nextButton == HIGH)) {
    //let's go one pic forward
      if (bmpcount < bmpmaxnumber){
        bmpcount++;
      } else {
        bmpcount = bmpmaxnumber;
      }
     
      bmpname = "image_" + String(bmpcount) + ".bmp";
      bmpDraw(bmpname, 0, 0);
     
   
   
    }
   
    if ((prevButton == HIGH) && (nextButton == LOW)) {
    //let's go one pic back
   
      if (bmpcount > 1){
        bmpcount--;
      } else {
        bmpcount = 1;
      }
     
      bmpname = "image_" + String(bmpcount) + ".bmp";
      bmpDraw(bmpname, 0, 0);
   
    }

}

Thank you!  I'll give it a try as soon as I can.  I'm in the middle of painting everything and this may have to wait a bit.  I do appreciate the response and will let you know what my results are.

Logged
Cabur Akaata #104, S.P.A.R.K. #22, Grey Brigade #48, M.L.C.S. #36, M.V.S. #55, Mando Riders #40, O.O.O.P.S. #23
 


Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today!
Official Members also get to use the forum ad-free - so kit up and join us!




Powered by EzPortal
anything