Show Posts
Pages: 1 ... 15 16 [17] 18 19 ... 253
241  Using Arduino / Project Guidance / Re: Animatronic Iron Man Suit Feasibility on: August 18, 2014, 09:53:49 am
There was another person who made a Iron man helmet where the face plate opens and closes. I can't find the post, but i'm sure its here somewhere. Found it, LINK

Anyway, I was thinking maybe you can use a capacitive touch sensor on the outside of the helmet to activate the helmet. Its looks better then a normal button, but then again, anyone can use/touch it. If this is not a problem then give it a try.

The code is simple, the only thing you need to worry about is where your going to fit everything and still make it look good. You might be able to do everything with an ATtiny (which one exactly, im not sure) which will allow you to compact everything into a small space.
242  Using Arduino / Project Guidance / Re: Displaying variable on TFT on: August 17, 2014, 09:04:14 pm
Like Roger, I don't have your hardware either, so I can't do any actual tests.

Your best bet would be to use sprintf().

Code:
void loop()
{
  char str[4]; // you dont need to constantly remake the array, so this line can be put before setup()
  sprintf(str, "%d", analogRead(A9)); // converts the numerical value to a string and stores it in the array.

  Tft.drawString(str,0,160,1,CYAN); // print the array.
}
243  Using Arduino / Project Guidance / Re: Displaying variable on TFT on: August 17, 2014, 07:19:26 pm
It seems to be displaying ascii characters.

Test this to see if the screen shows 123, and if it does, simply replace 123 with map(analogRead(A9), 0, 1023, 0, 100);

Code:
void loop()
{
  char str[4];
  *str = 123;
Tft.drawString(str,0,160,1,CYAN);
}
244  Using Arduino / Project Guidance / Re: Displaying variable on TFT on: August 17, 2014, 06:46:06 pm
char str[0]; basically your not making an array, it should be atleast char str[1].

Try this instead.
Code:
void loop()
{
  int flevel = map(analogRead(A9), 0, 1023, 0, 100);

  Tft.drawChar(flevel,150,0,3, RED);
  delay(1000);
  Tft.drawChar(flevel,150,0,3, BLACK);

}
245  Using Arduino / Project Guidance / Re: Displaying variable on TFT on: August 17, 2014, 06:18:08 pm
Use int instead of char fro storing the value from analogRead().

Also when your using arrays and a function that is looking for a string, you need to use pointers.

Try drawChar instead of drawString, like Tft.drawChar(str[0],0,160,1,CYAN);
246  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 07:48:01 pm
Yea I know, what I highlighted in my last reply is the line in the code you need to change.

Actually, there is another line that also says Main menu, it might be the one you need to change.

Quote
// create the various menus setting the items, font size, spacing, padding, justification and titles
TouchScreenMenu paddingSubMenu = TouchScreenMenu(paddingSubMenuItems, 2, 5, 20, CENTERJ, "Padding");
TouchScreenMenu spacingSubMenu = TouchScreenMenu(spacingSubMenuItems, 2, 40, 5, CENTERJ, "Spacing");
TouchScreenMenu smallSubMenu = TouchScreenMenu(smallSubMenuItems, 1, 10, 5, CENTERJ, "Small Font");
TouchScreenMenu rightSubMenu = TouchScreenMenu(rightSubMenuItems, 2, 10, 5, RIGHTJ, "Right Justify");
TouchScreenMenu leftSubMenu = TouchScreenMenu(leftSubMenuItems, 2, 10, 5, LEFTJ, "Left Justify");
TouchScreenMenu subMenu = TouchScreenMenu(subMenuItems, 2, 10, 5, CENTERJ, "Sub Menu");
TouchScreenMenu mainMenu = TouchScreenMenu(mainMenuItems, 2, 10, 10, CENTERJ, "Main Menu");
247  Development / Other Software Development / Re: New peek function for HardwareSerial on: August 16, 2014, 05:12:36 pm
@robtillaart
I just downloaded version 1.5.7, and I guess the permissions were changed back, because your code doesn't work anymore.

Edit:
I downloaded 1.5.6 r2 and it doesn't work either, I got the exact same error message :/

Error message:
Quote
Arduino: 1.5.7 (Windows 8 ), Board: "Arduino Uno"

In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h: In function 'void loop()':
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:101:51: error: 'unsigned char HardwareSerial::_rx_buffer [64]' is protected
     unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];
                                                   ^
sketch_aug16a.ino:9:18: error: within this context
In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:93:32: error: 'volatile rx_buffer_index_t HardwareSerial::_rx_buffer_head' is protected
     volatile rx_buffer_index_t _rx_buffer_head;
                                ^
sketch_aug16a.ino:11:18: error: within this context
In file included from C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/Arduino.h:221:0,
                 from sketch_aug16a.ino:1:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino/HardwareSerial.h:94:32: error: 'volatile rx_buffer_index_t HardwareSerial::_rx_buffer_tail' is protected
     volatile rx_buffer_index_t _rx_buffer_tail;
                                ^
sketch_aug16a.ino:13:18: error: within this context

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
248  Development / Other Software Development / Re: New peek function for HardwareSerial on: August 16, 2014, 04:20:52 pm
Well if you think about, all we need to do is access the buffer. The only problem that I can't seem to figure out is how to access the buffer

From HardwareSerial.cpp file.
Quote
struct ring_buffer
{
  unsigned char buffer[SERIAL_BUFFER_SIZE];
  volatile unsigned int head;
  volatile unsigned int tail;
};

Is there any way to access this struct outside the library?
249  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 04:03:07 pm
You mean this line here?

Quote
#include <TouchScreenMenu.h>
#include <TouchScreen.h>
#include <TFT_old.h>
#include <cstddef.h>

// create the array of items for the first sub menu
TouchScreenMenuItem subMenuItems[] = {
  TouchScreenMenuItem("<- Main Menu"),
  TouchScreenMenuItem("Left Justify"),
  TouchScreenMenuItem("Right Justify"),
  TouchScreenMenuItem("Small Font"),
  TouchScreenMenuItem("Spacing"),
  TouchScreenMenuItem("Padding"),
  TouchScreenMenuItem("ENDOFMENU")
};
250  Development / Other Software Development / New peek function for HardwareSerial on: August 16, 2014, 03:55:26 pm
I was trying to help out a new user with his project, but the solution I though would work turned out to only work once.

Users post
The user wanted to send a string from his phone to control a RGB led(s), and the code I gave him was:

Code:
char * strings[3] = {
  "RED", "GREEN", "BLUE"};
byte i = 0;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if(Serial.available())
  {
    while(i < 3)
    {
      if(Serial.find(strings[i]))
      {
        Serial.print("Found ");
        Serial.println(strings[i]);
        i = 0;
        break;
      }
      Serial.println(i);
      i++;
    }
    if( i >= 3)
    {
      Serial.println("not found");
      i = 0;
    }
  }
}

This code should check the buffer and see if a string is found, and if not increment the index and check again.

It will find RED if typed in because it is in the first index of the strings array, but it won't find anything else. Upon further investigation, I found out that read() pops the ints (look at the .h and .cpp files for HWS) out of the buffer when it is called so this prevents my code from working. However another function peek() only looks at the first index of the buffer and doesn't move unless read is called.

I would like to add a new peek() function that allows the user to look through the buffer freely without popping anything out, thus allowing my code to work.

I have made an equivalent code that does what I want using the normal HWS library, but it is not very elegant. I'm sure I am not the only person this new function would help, so I am asking if it can be added.

New peek function, simple right?
Code:
int HardwareSerial::peek(uint8_t position)
{
  if (_rx_buffer->head == _rx_buffer->tail) {
    return -1;
  } else {
    return _rx_buffer->buffer[position];
  }
}
251  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 03:15:54 pm
Oh, I put in the wrong file in, sorry.  smiley-lol

Try this one. Same sketches and unpacking procedure.
252  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 02:50:05 pm
You don't have to use those exact resistor values, but it does take only 2 different values.

example:
1000 and 4700

You can play around with the resistors to give you a better range if needed.
253  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:21:10 pm
True it's not pretty but it works good. If the picture is too big, I am sorry.
254  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:13:35 pm
I made a library for this very problem. Check it out.
Pay close attention as to how the keypad is wired, and the resistor configuration.

OneWireKeypad
255  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 10:22:01 am
You should have a folder called "libraries" located in your arduino sketch folder.
Pages: 1 ... 15 16 [17] 18 19 ... 253