Show Posts
Pages: 1 ... 41 42 [43] 44 45 ... 86
631  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.
632  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.
633  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.
634  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].
635  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.
636  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.
637  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.
638  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.
639  Using Arduino / Displays / Re: utft code issues on: March 25, 2013, 03:11:05 am
Are your buttons overlapping?
640  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.
641  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.
642  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.
643  Using Arduino / Programming Questions / Re: Convert array of integers to integer on: March 21, 2013, 05:19:01 pm
do you mean array1 [1, 2, 3] (ie 3 separate number?)

array[0]*100 + array[1]*10 + array[2]

generally you can put this in a loop for the same effect
Code:
int sum = 0;
for (uint8_t i=0; i<MAX_DIGITS; i++)
  sum = (sum*10)+array[i];
644  Using Arduino / Programming Questions / Re: Run loop for fixed duration on: March 21, 2013, 05:15:38 pm
Look at the blink without delay example for how to use millis() to time stuff.

Basically in loop()
1. If trigger is not set, return
2. starttime = millis()
3. while ((millis() - starttime) < running time of the loop) do the code in the loop
645  Using Arduino / Displays / Re: utft code issues on: March 21, 2013, 05:09:46 pm
It would be helpful if you could include the actual error message?

Code:
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
     
      if (50>=MainScreen && 100<= MainScreen && 100>= MainScreen && 170<MainScreen)
      {
         ScreenTo(0, 0, 300, 300);            //
      }

What is the variable MainScreen and where is it declared? I would have thought you should be comparing 50, 100, 170, etc to the variables x and y, which contain the coordinates you read form the touchscreen.

I would suggest that you should start on simpler examples of how to use variables and structure code. The examples that come with the Arduino IDE are a good place to read and understand how some of these basic concepts work. Once you have done that, maybe attempt this project, which is more complex.
Pages: 1 ... 41 42 [43] 44 45 ... 86