Show Posts
Pages: 1 ... 34 35 [36] 37 38 ... 80
526  Using Arduino / Programming Questions / Re: isolating a digit on: April 03, 2013, 09:08:03 pm
The modulus operator gives you the remainder when you divide the number by the divisor.

So 16 mod 10 = 6, because 10 fits into 16 once with remainder 6. 42 mod 10 = 2, etc
527  Using Arduino / Audio / Re: MSGEQ7 IC on: April 03, 2013, 05:12:26 pm
Timing values for strobe/reset/reads are given in the datasheet for these devices. I think they are in terms of microseconds rather than seconds.
528  Using Arduino / Programming Questions / Re: Writing a library? (Beginner) on: April 01, 2013, 04:54:04 am
I did a countdown timer using 7 segment LEDs. You may get some ideas on structure and functions by looking at that code. You can find it at with my code at the web site linked from my signature below.
529  Using Arduino / General Electronics / Re: L298 current sensing... how does it work? on: March 31, 2013, 02:45:02 am
You sense the voltage at the resistor. This is proportional to the current, related by ohms law. The resistor Values are generally quite low so that there is a small voltage drop. Chunky resistors are needed because they could be dissipating quite a low of power, as the currents could get quite high.

It is basically a voltage divider like you would use in other situations with the arduino.
530  Using Arduino / General Electronics / Re: RTC DS1307 is too slow on: March 29, 2013, 04:02:17 pm
Download the datasheet for the ds1307 and check if the crystal and capacitor are the correct values. The crystal is the only thing that sets the speed of the clock. Datasheet can be found using google.
531  Using Arduino / Programming Questions / Re: Dumb Question - Global variable not holding value on change on: March 28, 2013, 02:53:18 pm
Post all the code. In these sorts of issues the problem is not generally where you see the failure but somewhere else.
532  Using Arduino / Storage / Re: How to make the file name being dynamic for my project? on: March 28, 2013, 02:45:01 pm
You need to give name[] a size. File names can be 8.3 format so a size of 13 characters is enough (8+1+3+1). You need to declare name [13].
533  Using Arduino / Displays / Re: utft code issues on: March 27, 2013, 08:10:02 pm
Code:
#include <UTouchCD.h>

// UTFT_Demo_320x240

#include <UTFT.h>
#include <UTouch.h>
// Declare which fonts we will be using
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

// Uncomment the next line for Arduino Mega
UTFT myGLCD(ITDB32S,38,39,40,41);   // Remember to change the model parameter to suit your display module!
UTouch  myTouch(6,5,4,3,2);

uint8_t curScreen = 0;

void setup()
{
  // Setup the GLCD
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);

  myGLCD.print("PC CONTROLLER", CENTER, 303);
  delay(3000);
}

void loop()
{
  switch (curScreen)
  {
  case 0:
    MainScreen(50, 100, 100, 170);
    break;

  case 1:
    ScreenTo(0, 0, 300, 300);
    break;

  default:
    curScreen = 0; // restart if anything goes wrong
  }
}


bool checkButtonPressed(int X1, int y1, intX2, int y2)
{
  if (myTouch.dataAvailable())
  {
      int x,y;
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();

    if ((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2))
      return(true);
  }

  return(false);
}


void MainScreen(int x1, int y1, int x2, int y2)
{
  static bool bInitialised = false;

  if (!bInitialised)
  {
    myGLCD.clrScr();
    //                               L,R   up, down
    myGLCD.print("Main Screen", CENTER, 300);
    myGLCD.drawRoundRect(x1, y1, x2, y2);        // Draw a rectangle
    bInitialised = true;
  }
  else
  {
    if (CheckButtonPressed(x1, y1, x2, y2))
    {
      curScreen = 1;
      bInitialised = false;
    }
  }
}


void ScreenTo(int x1, int y1, int x2, int y2)
{
  static bool bInitialised = false;

  if (!bInitialised)
  {
    myGLCD.clrScr();
    //                 T,L  B,L  T,R  B,R 
    myGLCD.drawRoundRect(x1, y1, x2, y2);        // Draw a rectangle
    myGLCD.print("M", 54, 385);
    bInitialised = true;
  }
  else
  {
    if (CheckButtonPressed(x1, y1, x2, y2))
    {
      curScreen = 0;
      bInitialised = false;
    }
  }
}

You'll need to make sure it compiles and then debug the logic, as I am nowhere near anything that allows me to do that, but you have the basics in this code.
534  Using Arduino / Displays / Re: utft code issues on: March 26, 2013, 07:22:50 pm
When you display a screen, set a variable to say that that screen is being displayed. Then whe nyou are checking the buttons, if the variable says screen x, then check for thethe buttons for screen x, if screen y, then the buttons for screen y, etc.

You need to use an if statement to make the selection of which logic to use at the time.
535  Using Arduino / LEDs and Multiplexing / Re: Crossfader Arduino Tutorial on: March 25, 2013, 05:02:24 pm
you need to use unsigned number (int or char?) or uint8_t.

signed byte is -128 to 127, unsigned gives the full positive range 0-255.
536  Using Arduino / Displays / Re: utft code issues on: March 25, 2013, 05:00:15 pm
Unless you are reading two physically separate touchscreens, which does not seem to be the case in your code, you should only check the button depending on which screen is being displayed. Otherwise you are checking for all the buttons all the time, no matter what screen is being displayed.
537  Using Arduino / Displays / Re: utft code issues on: March 25, 2013, 03:11:05 am
Are your buttons overlapping?
538  Using Arduino / LEDs and Multiplexing / Re: Crossfader Arduino Tutorial on: March 25, 2013, 03:08:44 am
Quote
so for yellow = (40,95,0)  i calculate RGB = (102,242,0)  but when I enter these rbg value in photoshop I see a green color not yellow. What am I missing?

So if you enter (40,95,0) what do you get?

The comments in code (unfortunately) sometimes don't match what the code does. I agree that expressing RGB as % makes no sense whan the values are 0-255 anyway.
539  Using Arduino / Displays / Re: utft code issues on: March 23, 2013, 05:32:33 pm
Think about what the values of the variables should be. Their names is a big clue.
540  Using Arduino / Displays / Re: How do you create a siren like led effect? Is there a component to do that? on: March 22, 2013, 04:03:54 pm
The Multiblink sketch at my web site (see below in the signature block) implements that sort of flashing as an example. It came up a while ago when I was helping someone else. The pattern was something like two flashes on one side of the vehicle and two on the other. Anyway, if the pattern is not there it is easy enough to modify the program data to get what you need.
Pages: 1 ... 34 35 [36] 37 38 ... 80