Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 253
766  Development / Other Software Development / Re: New TFT Extension Library on: May 09, 2014, 08:38:49 pm
Slight update with Keyboard functions. New Font added!

Put new font into UTFT folder.

Game: Don't Block Me, is now able to be played in both landscape and portrait modes.
Just change this line #define Orientation LANDSCAPE to either LANDSCAPE or PORTRAIT, then upload to arduino.

Added:
Game: Connect_Four, now has falling animation and fixed "Host/Guest screen"
767  Using Arduino / Project Guidance / Re: I NEED HELP ANYONE PLEASE on: May 08, 2014, 09:11:40 pm
You need to make a 5x5 keypad and use the keypad library. Or if you can find one online, that works too.
768  Using Arduino / Programming Questions / Re: Do you think my program will work? on: May 08, 2014, 05:33:53 pm
That delay is reason it takes 27 second to turn. Take the delays out.
769  Using Arduino / Programming Questions / Re: Do you think my program will work? on: May 08, 2014, 05:15:24 pm
No, 27 seconds is the overall delay if that function.
770  Using Arduino / Programming Questions / Re: Do you think my program will work? on: May 08, 2014, 04:34:48 pm
Quote
if(cm2<30,cm>30)

Two possible ways it should be.
You either want the values to between cm2<30 or cm>30 or cm2<30 and cm>30
771  Using Arduino / Programming Questions / Re: Do you think my program will work? on: May 08, 2014, 04:31:13 pm
@UKHeliBob
Not only that, but look at his microsecondsToCentimeters function.

Something in here is not right either.
Quote
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();

What does this do?
Quote
  for(int i = 0; i < avgrange ; i++)
  {
    anVolt = analogRead(maxsonar)/2;
    sum += anVolt;
    delay(10);
  } 

  inches = sum/avgrange;
  cm2 = inches * 2.54;

  sum = 0;

Im guessing this is his attempt at PWM.
Quote
if (cm2>30,cm>30 )
  {
    digitalWrite(moteur,HIGH);
    delay(1000);
    digitalWrite(moteur,LOW);
    delay(500);
    digitalWrite(moteur,HIGH);
    delay(1000);
    digitalWrite(moteur,LOW);
    delay(500);
    digitalWrite(moteur,HIGH);
    delay(1000);
    digitalWrite(moteur,LOW);
    delay(500);
  }

Right now, this code is not going to work at all, at least not the way he wants it to.
772  Using Arduino / Project Guidance / Re: Speed measurement (Help Please) on: May 08, 2014, 12:38:02 pm
You can have a lockout condition in both timer functions.

Something like this.
void SensorOneState()
{
  if( !S1_locked ) // S1_locked is originally set to false
  {
    SensorOne_timer = millis(); //record the time the car reaches the first gate
    GotFirstSensor = true;
    S1_locked = true; // this locks out the function from restoring a new time until S1_locked is set back to false.
  }
}

void ClearStates()
{
  GotFirstSensor= false;
  GotSecondSensor = false;
  S1_locked = false;
  S2_locked = false;
}
773  Using Arduino / Programming Questions / Re: Graph drawing from array woes. on: May 08, 2014, 03:59:05 am
Well then, I am out of ideas.
774  Using Arduino / Programming Questions / Re: Graph drawing from array woes. on: May 08, 2014, 12:29:01 am
Have you though about your SRAM? 72*72 = 5184, now you made them ints, so now thats 10368 of the 2K on an UNO or 4K on a Mega.  smiley-roll-sweat

Why do you need to record everything? Why not just draw the points as the data comes in? Of course you need two sets of coordinates, so that's where you have n_X/Ypoint(new) and o_X/Ypoint(old)

I'm sure you can work out the rest from there.

If you really need to record everything then look into other means of storage, like SD cards or maybe even use the Heap (limited there too).
775  Using Arduino / Project Guidance / Re: School Project on: May 07, 2014, 05:00:08 pm
An arduino seems a bit overkill for this kind of project. All you would need is your buzzer, a transistor and some resistors.
776  Using Arduino / Project Guidance / Re: Battery advice for my project on: May 07, 2014, 04:23:35 pm
The one I suggested can be used while charging, but it will take longer to get to fully charged.
777  Using Arduino / Project Guidance / Re: Simple time display, set with two buttons [no extra hardware] on: May 07, 2014, 04:17:04 pm
Yea, that's possible. The buttons just add 1 their unique variables, and if they go beyond 12 or 23(H), reset back to 0, and same for minutes.
778  Using Arduino / Project Guidance / Re: Battery advice for my project on: May 07, 2014, 02:52:34 pm
Take a look at this one too. DC 12V Super Litium Battery There are all different sizes that can output from 1800mAh to 15000 mAh. They take about 6 hours to fully charge, but they can hold that charge for a very LONG time, even under constant uses.
779  Using Arduino / Project Guidance / Re: Speed measurement (Help Please) on: May 07, 2014, 02:40:57 pm
Sure that's ok.

Might I make a suggestion for your display?
Code:
#include <UTFT.h>
#include <UTouch.h>

#define MPS_to_KPH 3.6 // MPS to KPH
#define DISTANCE 1.9959 // mts
#define swap(type, A, B) {type T = A; A = B; B = T;}

float Speed = 0, KPH = 0, tmp = 0;
boolean GotFirstSensor= false, GotSecondSensor = false;
unsigned long SensorOne_timer = 0, SensorTwo_timer = 0;

extern uint8_t SmallFont[];
extern uint8_t BigFont[];

UTFT   myGLCD(ITDB32S,38,39,40,41); 
UTouch  myTouch(6,5,4,3,2);

void setup()
{
  //Serial.begin(115200);
  attachInterrupt(5, SensorOneState, FALLING); //Mega pin 18
  attachInterrupt(4, SensorTwoState, FALLING); //Mega pin 19
 
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
  myGLCD.fillScr(0,0,0);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 226, 319, 239);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("Speed Test", CENTER, 1);
 
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.setFont(BigFont);
  myGLCD.print("KM/h:",0,60);
  myGLCD.print("Time:", 0, 30);
  drawText ();
}

void loop()
{
  // This is using normal buttons to detect car passing through one gate to another,
  // this can be changed to use US sensors to replace the buttons. That part you will 
  // need to write yourself.

  if(GotFirstSensor & GotSecondSensor) //both must be true for this condition to be true
  {
    Speed = GetSpeed(SensorOne_timer, SensorTwo_timer, DISTANCE); // send the times and the distance into the function.
    //myGLCD.print("KM/h:",0,60);
    //myGLCD.printNumI(Speed, 60 ,120 );
    myGLCD.setBackColor(0, 0, 0);
    myGLCD.setFont(BigFont);
    myGLCD.printNumF(Speed,2,90,60);
    ClearStates();
  }
 
}

void SensorOneState()
{
  SensorOne_timer = millis(); //record the time the car reaches the first gate
  GotFirstSensor = true;
}

void SensorTwoState()
{
  SensorTwo_timer = millis(); //record the time the car reaches the second gate
  GotSecondSensor = true;
}

void ClearStates()
{
  GotFirstSensor= false;
  GotSecondSensor = false;
}

float GetSpeed(unsigned long T1, unsigned long T2, float distance)
{
  KPH = distance * (MPS_to_KPH); // "(FPS_to_MPH)" -> conversion factor, feet per second to miles per hour
  if(T1 > T2) // this here is what allows it to calculate the speed from both directions.
    swap(unsigned long, T1, T2);
   
  tmp = (T2 - T1)/1000.0000; // since the time we are using is in milliseconds, we need to convert milliseconds to seconds
  //myGLCD.print("Time:", 0, 30);
  myGLCD.printNumF(tmp,4, 90, 30);
  return (KPH / tmp); //return the speed of the car in MPH
}

void drawText()
{
    myGLCD.setBackColor(0, 0, 0);
   
    myGLCD.setFont(SmallFont);
    myGLCD.print("dV:0.01 Km/h" ,LEFT, 120);
    myGLCD.setFont(BigFont);
    //myGLCD.print("Km/h", 160, 95);
   
    myGLCD.setColor(64, 64, 128);
    myGLCD.fillRoundRect(10, 180, 70, 220);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect(10, 180, 70, 220);
    myGLCD.setBackColor(64, 64, 128);
    myGLCD.setFont(SmallFont);
    myGLCD.print("Save", 20, 190);
    myGLCD.setBackColor(0, 0, 0);
 
    myGLCD.setColor(64, 64, 128);
    myGLCD.fillRoundRect(80, 180, 140, 220);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect(80, 180, 140, 220);
    myGLCD.setBackColor(64, 64, 128);
    myGLCD.setFont(SmallFont);
    myGLCD.print("Borrar", 85, 190);
    myGLCD.setBackColor(0, 0, 0);
   
    myGLCD.setColor(64, 64, 128);
    myGLCD.fillRoundRect(150, 180, 210, 220);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect(150, 180, 210, 220);
    myGLCD.setBackColor(64, 64, 128);
    myGLCD.setFont(SmallFont);
    myGLCD.print("Log", 155, 190);
    myGLCD.setBackColor(0, 0, 0);
 
    myGLCD.setColor(64, 64, 128);
    myGLCD.fillRoundRect(220, 180, 280, 220);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect(220, 180, 280, 220);
    myGLCD.setBackColor(64, 64, 128);
    myGLCD.setFont(SmallFont);
    myGLCD.print("Hist", 225, 190);
    myGLCD.setBackColor(0, 0, 0);

}

I made a library that can be used with the UTFT and UTouch libraries. Here is the link, TFT_Extension Newest update at reply #35. I included a lot of examples you can play around with.
780  Using Arduino / Project Guidance / Re: Speed measurement (Help Please) on: May 07, 2014, 12:15:53 pm
The mega can do it but you just need to make sure your other components are compatible with each other. Make sure you get a touch screen that does not take up the same pins that the SD card does or the RTC, for they may not work. However most touch screens has SD card readers, so you should be good there.
Pages: 1 ... 50 51 [52] 53 54 ... 253