Show Posts
Pages: 1 ... 53 54 [55] 56 57 ... 228
811  Using Arduino / Project Guidance / Re: How to make my own board which sends me accelerometer data via bluetooth on: February 13, 2014, 10:00:55 am
Goal: An Arduino based board that runs over battery (of course) having accelerometer + gyro and bluetooth(BLE). This board should be as small as possible and sends the accelerometer and gyro info via bluetooth.

That should be easy if you can get your hands on the chips used from the accel/gyro, an Arduino Nano, Micro or Mini, and the Bluetooth module. There is also barebones Arduinos, meaning you get the components and you can make your own Arduino board.

Personally the barebones would be the better solution for compactness, if you can't get the chips used as stated above. An alternative would be to buy the parts stated above already assembled and wire them up. But since you know how to use Eagle software, you should look into barebones Arduinos.
812  Using Arduino / Programming Questions / Re: Arrays inside of a array on: February 12, 2014, 11:15:45 pm
I'm not going to ask about your logic with the IF statement, but you have a 2D array so the compiler wants it to be int L[][2]
813  Using Arduino / Programming Questions / Re: Problem with append to char array (from KEYPAD) on: February 12, 2014, 07:23:53 pm
Try this:

void readPassEeprom()
  byte location;
  byte digit;

  for (location=0;location<=3;location++)
    st_pass[location]= (digit >= 127? NULL : digit); // look at each value from eeprom @ location, if value is not a char, set NULL, otherwise value is char.

  if( strlen(st_pass) == 4 ) // check is st_pass is a valid password
    Serial.print("Password is valid: ");
  else  // st_pass is not valid, so make st_pass be "4444"
    strcpy(st_pass, "4444"); // this sets st_pass to "4444"
    Serial.print("Invalid password, Auto set to: ");
  Serial.print("Set pass to: ");
814  Using Arduino / Project Guidance / Re: HOW TO USE KEYPAD FOR MAKE A CONTROL ACCESS SISTEM on: February 12, 2014, 06:28:39 pm
They can be changed, those are just initial passwords. You can use the same method like how it is done in the beginning, to change them later in the code. You will need a way to wait for keypress then one by one store them in the EEPROM. Make sure you set a limit otherwise it will give you problems and may write over other passwords.

I am unable to provide an example at the moment but someone else may be able to.
815  Using Arduino / Programming Questions / Re: Reusing code meant for the Adafruit LCD with buttons shield on: February 10, 2014, 09:21:57 pm
Where is your loop function? And why are you still breaking up the code, if you want help I need to see the code in full, not parts. You can add an attachment under additional options at the bottom when you make a new reply.

Looking at your link, those buttons use one analog pin A0 to read the buttons. This is done with a resistor ladder, meaning the code itself is already designed to work with the resistor values. However your buttons are the basic one pin per button, so I have to ask how are your buttons wired? Are they normally High or Low, are you sure they have some stable connection to the board when the button is not press and the pin is floating?

I also see that you are not debouncing the buttons like you should nor are you checking to see if they are being held down or not. I'm guessing you are brand new to using an Arduino or maybe even coding altogether, but the Arduino software comes with examples you can play with, learn from and adapt to your code. There are quite a few things that need to be fixed, but seeing as your code mostly revolves are your buttons at the moment, I suggest you iron out their flaws first.
816  Using Arduino / Programming Questions / Re: Reusing code meant for the Adafruit LCD with buttons shield on: February 10, 2014, 07:19:54 pm
Post your full code, not in parts. Make sure you add comments too.
817  Using Arduino / Project Guidance / Re: Elevator lights control panel. on: February 09, 2014, 11:48:36 pm
For that you will need shift registers, 3x 16bit or 6x 8bit.
818  Using Arduino / Project Guidance / Re: Elevator lights control panel. on: February 09, 2014, 11:21:43 pm
Simple enough. You can start with a small scale model, a few LEDs and two buttons to get the code started. There are plenty of examples you can try with the arduino software. I worked for an elevator manufacturing company in the past, so if memory serves me right, those are 12V LEDs and if it is an old panel, they might be 120V bulbs.

As for speed, you can use the floor buttons (if you can) to set the speed.
819  Using Arduino / Project Guidance / Re: password activated garage on: February 09, 2014, 05:06:27 pm
If you want, you can check out my password library. It is designed for multiple passwords and users.

Newer version at bottom of page LINK HERE
820  Using Arduino / Programming Questions / Re: TFT LCD analog gauge on: February 09, 2014, 04:48:58 pm
I think this is more of what you want.

Note the changes and the ones need to work with my screen.

//#include <UTFT.h>
#include <ITDB02_Graph16.h>
extern uint8_t SmallFont[];
//UTFT myGLCD(ITDB32S, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
ITDB02 myGLCD(A1,A2,A0,A4,A5,2);

double pi = 3.14159265;
double x = 0, oldx = 50; // setting variable to 0 is not needed, it will be written over anyways, it just looks good.
double y = 0, oldy = 50;// same as above
int rad = 50; // radius 50 pixels
void setup()
  myGLCD.setBackColor(50, 50, 50);

double mD(double data, double in_min, double in_max, double out_min, double out_max)//Map double
  return (data - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

void drawNeedle(int sensor,int pos_x, int pos_y){
  double cur = mD(analogRead(sensor),0,1023,0,pi);
  x = pos_x + sin(cur + (pi/2)) * rad;
  y = pos_y + cos(cur + (pi/2)) * rad;

  if(x != oldx && y != oldy)
    myGLCD.drawLine(oldx, oldy,pos_x,pos_y); 
    myGLCD.drawLine(x, y,pos_x,pos_y); // (cx, cy, calculated x, calculated y)
    oldx = x;
    oldy = y;
    myGLCD.printNumF(cur,2,CENTER,10);//used for debugging 

void loop(){
  //delayMicroseconds(30000);//Added to reduce flickering
821  Using Arduino / Programming Questions / Re: Need help referencing two classes in one constructor. on: February 09, 2014, 06:12:37 am
The issue with the code only returning the # was because in the Calc function I originally made, it started the calculations at zero to store the first value ie 1023. Now when you made the code do it on the fly, it again started from 0 and it saw that every analog value was less than 1023  so it never incremented the keypad array. In short, to get the proper readings you have to calculate everything backwards to output the right keypad chars.

Another thing, no I don't need the lcd attached to compile the code, I'm not sure why your getting that error. Do you have the Liquidcrystal_I2C library?

Last thing, yes I understood everything you changed.
822  Using Arduino / Programming Questions / Re: TFT LCD analog gauge on: February 08, 2014, 07:46:59 pm
If you need the line to be thicker, you can use the fillrect function instead of drawLine, but it might look a little strobe like when it moves.
823  Using Arduino / Programming Questions / Re: Do I need the library WProgram.h on: February 08, 2014, 04:05:08 pm
Replace WProgram.h with Arduino.h, save it, then restart the arduino software.
824  Using Arduino / Programming Questions / Re: Need help referencing two classes in one constructor. on: February 08, 2014, 02:37:34 pm
I got it.

New .h Library:
#ifndef OWKPtest_h
#define OWKPtest_h

#include <Arduino.h>
#include "BitBool.h"

#define NO_KEY '\0'
#define WAITING 0
#define PRESSED 1
#define RELEASED 2
#define HELD 3

/*--- Main Class ---*/
template< typename T, unsigned MAX_KEYS >
class OWKPtest{
OWKPtest( T &port, char KP[], uint8_t Rows, uint8_t Cols, uint8_t Pin, int R1, int R2 )
: port_( port ), latchedKey( BitBool< MAX_KEYS >() ), _Data( KP ), _Rows( Rows ), _Cols( Cols ), _Pin( Pin ),
  holdTime( 500 ), startTime( 0 ), lastState( 0 ), lastRead( 0 ), debounceTime( 10 ), R1( R1 ), R2( R2 ) {}

char Getkey();
void SetHoldTime(unsigned long setH_Time)       { holdTime = setH_Time; }
void SetDebounceTime(unsigned long setD_Time)       { debounceTime = setD_Time; }
uint8_t Key_State();
bool Readpin()      { return analogRead(_Pin)? 1 : 0; }
void LatchKey();
bool checkLatchedKey(char _key);

T &port_;

BitBool< MAX_KEYS > latchedKey;   
char *_Data;                       
char Out[20];
uint8_t _Rows, _Cols, _Pin;
char lastKey;
enum{ SIZE = MAX_KEYS };           
unsigned long time;
unsigned long holdTime;
unsigned long startTime;
unsigned long debounceTime; 
    bool state, lastState, lastRead;
int R1, R2;   

template < typename T, typename U > struct IsSameType{
enum { Value = false };

template < typename T > struct IsSameType< T, T > {
enum { Value = true };

template < typename T, unsigned MAX_KEYS >
char OWKPtest< T, MAX_KEYS > :: Getkey()

   if( int Reading = analogRead(_Pin)){
if(millis() - startTime > debounceTime){
  for( byte i = 0, R = _Rows-1, C = _Cols-1; i < SIZE; i++ ){

float V = ( 5.0f * float( R2 ) )/( float( R2 ) + ( float( R1 ) * float( R ) ) + ( float( R2 ) *float( C ) ) );
float Vfinal = V * (1023.0f / 5.0f);

if( Reading <= ( int(Vfinal) + 1.9f ) ) return _Data[(SIZE-1)-i];

if( C == 0 )
  C = _Cols-1;
       else C--;
  startTime = millis();
  return NO_KEY;

template < typename T, unsigned MAX_KEYS >
uint8_t OWKPtest< T, MAX_KEYS > :: Key_State()
  if((state = Readpin()) != lastState)
return ( ( lastState = state ) ? PRESSED : RELEASED); //MOD
  else if(Readpin())
time = millis();

  if((millis() - time) > holdTime) return HELD;
lastState = 0;
return RELEASED;
  return WAITING;

template < typename T, unsigned MAX_KEYS >
void OWKPtest<T, MAX_KEYS > :: LatchKey()

  char output[20];
  bool PRINT = false;
  char read = Getkey();
  if(read != lastRead)
if( read )
  for( int idx = 0; idx < SIZE; idx++ )
if(read == _Data[idx] )
   strcpy_P( output, ( latchedKey[idx] = !latchedKey[idx] ) ? PSTR( "Key X was Latched" ) : PSTR( "Key X was Unlatched" ) ); //MOD
  PRINT = true;
  output[ 4 ] = read; //MOD <- very clever       
lastRead = read;
   if( PRINT ) //port_.println(output);
     if( IsSameType< T, LiquidCrystal_I2C >::Value)

template < typename T, unsigned MAX_KEYS >
bool OWKPtest< T, MAX_KEYS > :: checkLatchedKey(char _key)

  for( int idx = 0; idx < SIZE; idx++ )
if( _key == _Data[idx] ) return latchedKey[idx];   
  return false;

New Sketch:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "OWKPtest.h"

char KEYS[]= {
LiquidCrystal_I2C lcd(0x20,20,4);
OWKPtest <LiquidCrystal_I2C, 12> KP( lcd, KEYS, 4, 3, A0, 4700, 1000 );
OWKPtest <Print, 12 > KP2(Serial, KEYS, 4, 3, A0, 4700, 1000 );

void setup (){
void loop()
  if( KP.Getkey() ){
    lcd.print( F( "KP: " ) );

  if( KP2.Getkey() ){
    Serial.print( F( "KP2: " ) );
825  Using Arduino / Programming Questions / Re: Need help referencing two classes in one constructor. on: February 08, 2014, 09:39:33 am
Right after your last post, the one before this one, I changed the constructor to include Init, but I see that you also did Calc too.

Ok, I ran into a problem and I think the cause is your BitBool library. Getkey() should return the key that was pressed, however no matter what key I press, it always shows #. I'll see what the actual cause is.
Pages: 1 ... 53 54 [55] 56 57 ... 228