Show Posts
Pages: 1 ... 36 37 [38] 39 40 ... 252
556  Using Arduino / Project Guidance / Re: LCD menu's on: June 18, 2014, 07:34:11 pm
Use switchVar1 in a IF statement to increment a counter that cycles through the cases.
557  Using Arduino / Project Guidance / Re: LCD menu's on: June 18, 2014, 07:07:15 pm
Can you post a picture?
558  Using Arduino / Project Guidance / Re: LCD menu's on: June 18, 2014, 06:10:02 pm
Code:
byte shiftRegister()
{
  digitalWrite(backLight, HIGH);
 
  digitalWrite(latchPin, HIGH);
  delayMicroseconds(20);
  digitalWrite(latchPin, LOW);

  return shiftIn(dataPin, clockPin, MSBFIRST);
}

void loop()
{
  switchVar1 = shiftRegister(); // this should return 0 if nothing is pressed, if it constantly returning a value then something is wired wrong.

  if (switchVar1 == 32)
  {
    lcd.setCursor(0,1);
    lcd.write(Symbol_2);
  }
}
559  Using Arduino / Project Guidance / Re: LCD menu's on: June 18, 2014, 05:40:04 pm
Quote
the problem is, is that i want the shift register input values to do more than one thing
So call the shiftRegister function where you need it.

For the main menu, you can use case statements, and when you need to switch into the sub-menus, you call the shiftRegister function again.
560  Using Arduino / Displays / Re: Problem with initializing TFT on: June 18, 2014, 02:20:25 pm
I think it was changed to only require CS, DC and RST. However if you use the Adafruit library you can use what you have.

Quote
Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t sid,
 uint8_t sclk, uint8_t rst) {
  _cs   = cs;
  _rs   = rs;
  _sid  = sid;
  _sclk = sclk;
  _rst  = rst;
  hwSPI = false;
}
561  Using Arduino / Programming Questions / Re: Getting a steady output on a 1602 LCD display on: June 18, 2014, 02:05:29 pm
Try this.

Code:
#include <ShiftLCD.h>

ShiftLCD lcd(9, 11, 10);                                                                                                                                 //initializing the LCD adapter pins
unsigned int lightOutput[17] = {1, 0, 0, 8, 0, 0, 64,0, 254, 512, 0, 2048,0, 0, 0, 0, 0};         //for testing
unsigned int outputL = 0;
unsigned int lastInt = 0;

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
}

void loop() {
  // put your main code here, to run repeatedly:
  outputL = 0;
  for(int i=0; i < 17; i++)
  {                                           //loop through the light output array
       outputL += lightOutput[ i ];                            //adding up the numbers
  }                                             
  printBinary16(outputL);                                  //sending  the result to dislplay

}

void printBinary16(unsigned int iIn)
{
  if( iIn != lastInt)
  {
    lastInt =  iIn;
    byte hiByte = highByte(iIn);
    byte loByte = lowByte(iIn);
    int binValue = word(hiByte, loByte);

    for(int i=15; i>=0; i--)
    {
      lcd.setCursor(15-i, 0); // these might be backwards
      lcd.print( bitRead(binValue, i));
    }
  }
}
562  Using Arduino / Project Guidance / Re: Which Shield is Better to use Keyboard as an Input For Arudino on: June 18, 2014, 01:36:20 pm
Quote
what I should do to make the Computer give instructions to the Arduino like (WASD) Keys to go forward, back, left and right.

Yes, unless you have a joystick or gamepad that can send the commands instead.

edit:
From your computer, you can send WASD with a terminal program like puTTY and the arduino will need to receive that key( char pressed) and do the function assigned to it. You can use IF/ELSE statements or CASE statements.

Do you plan on sending multiple keys like "WA" to go forward and to the left?
563  Using Arduino / Programming Questions / Re: Getting a steady output on a 1602 LCD display on: June 18, 2014, 01:17:01 pm
What happens if you just show "123456789" and nothing else in the setup, does the screen still flicker?
void setup()
{
 /* fill in lcd.begin and other things */

 lcd.print("123456789");
}
564  Using Arduino / Project Guidance / Re: Which Shield is Better to use Keyboard as an Input For Arudino on: June 18, 2014, 12:58:08 pm
These modules are easy to use and setup, the default baud rate is 9600, but you can use AT commands to change that later.
I have four of these and they are quite good. JY-MCU Bluetooth Module

They can be used to communicate to a PC and most Android devices but are not supported with 99% of iOS device(depends on the app used. The only one that kinda worked was TouchOSC )
565  Using Arduino / Programming Questions / Re: Binary number to decimal. on: June 18, 2014, 09:28:29 am
Or if you actually looking for the conversion, then you would take each nibble from LSB to MSB and multiply it by 16 to the power of x.

0x1A2B3C -> (1 * pow(16, 5)) + (10 * pow(16, 4)) + (2 * pow(16,3)) + (11 * pow(16, 2)) + (3 * pow(16, 1)) + (12 * pow(16, 0))
= 171500410

Note: pow(16, x) = 16 ^ x (not XOR)
566  Using Arduino / Project Guidance / Re: Image Processing on: June 18, 2014, 08:33:41 am
Could you give a better explanation of how you want to "count" those objects? No arduino can do image processing. If you are dead set on using image processing, then you need to get  a RPi or a small computer that has enough memory and processing power.

A simpler solution would be to use IR or a laser beam, if the beam is cut then you know something has passed in front of it and so it gets counted. I don't think it is legal to take pictures of credit cards.
567  Using Arduino / Programming Questions / Re: incrementally declaring variables on: June 18, 2014, 08:19:42 am
Quote
void setValue (int value, int outputNumber, int outputPins[]) {
   
  for (int i=0; i<outputNumber; i++) {
     if (i<value) {
        digitalWrite(outputPins[ i ], HIGH);
     }
     else{
        digitalWrite(outputPins[ i ], LOW);
     }
  }
}
This is what he needs to use but instead of constantly making the pins HIGH or LOW, it should see if the value has first changed or not.

He could also get rid of "int outputNumber" if the code is changed to use what I did here.

Quote
#define SIZE(x) sizeof(x)/sizeof(x[0])  /* This should be added to the core library */

void setup()
{
  Serial.begin(115200);
  for(byte i = 0, j = SIZE(tmp); i < j; i++)
568  Using Arduino / Programming Questions / Re: incrementally declaring variables on: June 17, 2014, 09:39:40 pm
You could also do something like this.

Code:
byte tmp[]={1,2,3,4};
#define SIZE(x) sizeof(x)/sizeof(x[0])  /* This should be added to the core library */

void setup()
{
  Serial.begin(115200);
  for(byte i = 0, j = SIZE(tmp); i < j; i++)
    Serial.println(tmp[i]);
}
void loop() {}

Output:
Quote
1
2
3
4
569  Using Arduino / Project Guidance / Re: LCD menu's on: June 17, 2014, 08:27:06 pm
Do you have any code that you've been working on?
570  Using Arduino / Programming Questions / Re: Getting a steady output on a 1602 LCD display on: June 17, 2014, 06:38:11 pm
I think I was using either version 19 or 20 at the time that sketch was written.

If they fixed it since then, great; if not, then i'm not surprised. But I am used to writing with C strings, so I'm not going back any time soon.
Pages: 1 ... 36 37 [38] 39 40 ... 252