Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: Array problem , 3buttons and three leds on: February 03, 2013, 07:58:21 am
Hello all,

Quote
if Switch1 is press,LED1 light up, press the Switch1 again, LED1 turn off?
if Switch2 is press,LED2 light up, press the Switch2 again, LED2 turn off?
if Switch3 is press,LED3 light up, press the Switch3 again, LED3 turn off?

Yes this is the meaning about this sketch.

Quote
how do you connect the wire for the switches and LEDs?
do you have a pull-up/down for your switches?

These buttons are pull-down connected,

How can i make the Val and val_old as index ??

Greetz , ArduinoPat
17  Using Arduino / Programming Questions / Re: Array problem , 3buttons and three leds on: February 03, 2013, 07:31:56 am
Many thanks for quick reply Mark,

I have change the sketych and try this , but unfortunately it not works either,
Code:
// test 3 BUTTON , with 3 LEDS , Array.
// One Push Button , LED = ON and stay on !!
// After push the button , LED = OFF and stay off !!
// ArduinoPat

int LED [] = {11,12,13};  // the pin for the LED
int BUTTON[] = {7,8,9}; // the input for the BUTTON
                 
int val = 0;      // val will be used to store the state
                  // of the BUTTON pin
int old_val = 0;  // this variable stores the previous
                  // value of "val"
int state = 0;    // 0 = LED off and 1 = LED on

void setup()
{
  for(int index = 0; index < 3; index++)

{
  pinMode(LED[index], OUTPUT);   // tell Arduino LEDS is an output
  pinMode(BUTTON[index], INPUT); // tell Arduino BUTTON is an input
 
  digitalWrite(BUTTON[index],HIGH); // Pull-up Resistor
  }
 
}

void loop(){

    for(int index = 0; index < 3; index)                         
{
  int val  = digitalRead(BUTTON[index]);   // Against bouncing
  if ((val == HIGH) && (old_val == LOW))  // Against bouncing
  {
    state = 1 - state;                   // Against bouncing
    delay(10);                           // Against bouncing
  }

  old_val = val; // val is now old, let's store it

  if (state == 1) {     
    digitalWrite(LED[index], HIGH); // turn LED ON
  }
  else
  {
   digitalWrite(LED[index], LOW); // turn LED OFF
  }
}
}


Only by push the button connect at pin 7 will activate output pin 10,
the other pins will do nothing ;-((

Regards ArduinoPat,
18  Using Arduino / Programming Questions / Array problem , 3buttons and three leds on: February 03, 2013, 07:09:20 am
Hello,

I tryed the next sketch:

Code:
// test 3 BUTTON , with 3 LEDS , Array.
// One Push Button , LED = ON and stay on !!
// After push the button , LED = OFF and stay off !!
// ArduinoPat

int LED [] = {11,12,13};  // the pin for the LED
int BUTTON[] = {7,8,9}; // the input for the BUTTON
                 
int val = 0;      // val will be used to store the state
                  // of the BUTTON pin
int old_val = 0;  // this variable stores the previous
                  // value of "val"
int state = 0;    // 0 = LED off and 1 = LED on

void setup()
{
  for(int index = 0; index < 4; index++)

{
  pinMode(LED[index], OUTPUT);   // tell Arduino LEDS is an output
  pinMode(BUTTON[index], INPUT); // tell Arduino BUTTON is an input
 
  digitalWrite(BUTTON[index],HIGH); // Pull-up Resistor
  }
 
}

void loop(){

    for(int index = 0; index < 4; index)                         
{
  int val  = digitalRead(BUTTON[index]);   // Against bouncing
  if ((val == HIGH) && (old_val == LOW))  // Against bouncing
  {
    state = 1 - state;                   // Against bouncing
    delay(10);                           // Against bouncing
  }

  old_val = val; // val is now old, let's store it

  if (state == 1) {     
    digitalWrite(LED[index], HIGH); // turn LED ON
  }
  else
  {
   digitalWrite(LED[index], LOW); // turn LED OFF
  }
}
}

The meaning of this sketch is :
3 buttons , and 3 LEDs
push button one LED one is ON , and stay on ,after push again this button the LED goes off
Push button two LED two is ON , and stay on , after push again this button the LED goes off
Push button three LED three is ON , and stay on , after push again this button the LED goes off
also i have place a little sketch against bouncing during push the button,i think this is the problem it will not work ??

unfortunately this will not work,
Every button i push nothing happens.

Maybe someone can advice me what iám doing wrong ?

Greetz ,

ArduinoPat
19  Using Arduino / Networking, Protocols, and Devices / Re: SPI Led module Question on: January 25, 2013, 03:38:41 pm
When i start the sketch , the displays ( 8x ) are empty
I Open the Terminal and type 1 , the first 7segment is active now
when type two in the terminal , two appears at the first 7 segment , one is appeared at second 7 segement digit,

and this will go on till all (smiley-cool 7 segement displays are filled with a number.


Regards,

ArduinoPat
20  Using Arduino / Networking, Protocols, and Devices / Re: SPI Led module Question on: January 25, 2013, 02:42:04 pm
Hello PaulS,


Sorry for indistinct , but this is my question :

Quote
You can have one displaying something and 7 displaying nothing

Regards ,

ArduinoPat
21  Using Arduino / Networking, Protocols, and Devices / Re: SPI Led module Question on: January 25, 2013, 02:20:13 pm
Hi PaulS,

Now my next question,
How to bring these 7 segment LED ( 7 pc ) out of service and one still working ??

All these 74hc595 are coupled like a BUS ??? ( am i right ?? )

Maybe you can help to put me at the right direction,

I have tryed to find this at the sketch but there are no such kind of parameters regarding this ?

Code:
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 3;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 9;
byte Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("reset");
}
void loop() {
  if (Serial.available() > 0) {
    // ASCII '0' through '9' characters are
    // represented by the values 48 through 57.
    // so if the user types a number from 0 through 9 in ASCII,
    // you can subtract 48 to get the actual value:
  int bitToSet = Serial.read() - 48;
  // write to the shift register with the correct bit set high:
  digitalWrite(latchPin, LOW);
  // shift the bits out:
  shiftOut(dataPin, clockPin, MSBFIRST, Tab[bitToSet]);
    // turn on the output so the LEDs can light up:
  digitalWrite(latchPin, HIGH);
  }
}


I hope you can support me about this,

Regards,

ArduinoPat
22  Using Arduino / Networking, Protocols, and Devices / Re: SPI Led module Question on: January 25, 2013, 01:46:32 pm
Hello PaulS,

Now all displays ( 8 x 7segment leds display ) shows the count up or down.
But i mean , is this also possible to bring 7 segments "out of service "  and only one 7segment led display will show the count UP or down.



I hope you understand my question ,

Many thanks,

Regards

ArduinoPat
23  Using Arduino / Networking, Protocols, and Devices / SPI Led module Question on: January 25, 2013, 10:18:41 am
Hi All,

I have bought a SPI Led Module , find attached the link:
http://www.dfrobot.com/wiki/index.php?title=SPI_LED_Module_(SKU:DFR0090)

I test the sketch and it works , but is it possible to run one LED unit ??
Now all LED segments units are showing the same numbers ( Loop)

All is working with the 74HC595 ( 8x / led segment unit ) 

I hope it's possible to do this ?

Regards ,

ArduinoPat
24  International / Nederlands / Re: Toepassen Max 7219 , Matrix 8x8 Led on: January 20, 2013, 01:33:51 pm
Ik heb de een sketch al uitgevoerd zonder libraries , dit functioneert goed,

MAAR , Ben er achter gekomen dat de release 0022 wel werkt met de Max 7219
wel vreemd dat deze het eerst niet deed, heb hem twee keer geinstalleerd , en nu is het voor elkaar  smiley-roll

Hier zat het dus het probleem in dat deze op mijn versie niet werkt ( Versie 1.0 ) ??

Met Vriendelijke Groet,

ArduinoPat,

25  International / Nederlands / Re: Toepassen Max 7219 , Matrix 8x8 Led on: January 20, 2013, 09:01:45 am
Goedenmiddag Stealh0113,

Ik heb deze ook zo geplaatst in een Library Map,
Ook het example net zoals jou bijgevoegde file,

Zelf denk ik dat de Sprite.h en de Matrix.h niet juist zijn ?

Ik hoop dat iemand nog een andere invulling hierop geeft,

Alvast bedankt ,

ArduinoPat
26  International / Nederlands / Toepassen Max 7219 , Matrix 8x8 Led on: January 20, 2013, 08:23:19 am
Goedenmiddag ,

Ben aan het experimenteren met de MAtrix 8x8 en een Max7219,
Het programma welke ik wil toepassen is vanuit het Cookbook Page 280 , 7.13

**sketch niet hierin gezet met max overschrijding characters **

Maar loop nu vast op de Library, In het boek staat wel een verwijzing naar deze maar heb deze opgeslagen in de Library MAP.

Maar krijg de ene na de andere foutmelding.


Post aangepast :

Heb even de release 0022 geinstalleerd , maar het werkt helaas nog steeds niet:



De Library Matrix.ccp ziet er als volgt uit:

Code:
/*
  Matrix.cpp - Max7219 LED Matrix library for Arduino & Wiring
  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

// TODO: Support segment displays in api?
// TODO: Support varying vendor layouts?

/******************************************************************************
 * Includes
 ******************************************************************************/

extern "C" {
  // AVR LibC Includes
  #include <inttypes.h>
  #include <stdlib.h>

  // Wiring Core Includes
  #undef abs
  #include "WConstants.h"

  // Wiring Core Prototypes
  //void pinMode(uint8_t, uint8_t);
  //void digitalWrite(int, uint8_t);
}

#include "Sprite.h"
#include "Matrix.h"

/******************************************************************************
 * Definitions
 ******************************************************************************/

// Matrix registers
#define REG_NOOP   0x00
#define REG_DIGIT0 0x01
#define REG_DIGIT1 0x02
#define REG_DIGIT2 0x03
#define REG_DIGIT3 0x04
#define REG_DIGIT4 0x05
#define REG_DIGIT5 0x06
#define REG_DIGIT6 0x07
#define REG_DIGIT7 0x08
#define REG_DECODEMODE  0x09
#define REG_INTENSITY   0x0A
#define REG_SCANLIMIT   0x0B
#define REG_SHUTDOWN    0x0C
#define REG_DISPLAYTEST 0x0F

/******************************************************************************
 * Constructors
 ******************************************************************************/

Matrix::Matrix(uint8_t data, uint8_t clock, uint8_t load, uint8_t screens /* = 1 */)
{
  // record pins for sw spi
  _pinData = data;
  _pinClock = clock;
  _pinLoad = load;

  // set ddr for sw spi pins
  pinMode(_pinClock, OUTPUT);
  pinMode(_pinData, OUTPUT);
  pinMode(_pinLoad, OUTPUT);

  // allocate screenbuffers
  _screens = screens;
  _buffer = (uint8_t*)calloc(_screens, 64);
  _maximumX = (_screens * 8);

  // initialize registers
  clear();             // clear display
  setScanLimit(0x07);  // use all rows/digits
  setBrightness(0x0F); // maximum brightness
  setRegister(REG_SHUTDOWN, 0x01);    // normal operation
  setRegister(REG_DECODEMODE, 0x00);  // pixels not integers
  setRegister(REG_DISPLAYTEST, 0x00); // not in test mode
}

/******************************************************************************
 * MAX7219 SPI
 ******************************************************************************/

// sends a single byte by sw spi (no latching)
void Matrix::putByte(uint8_t data)
{
  uint8_t i = 8;
  uint8_t mask;
  while(i > 0) {
    mask = 0x01 << (i - 1);         // get bitmask
    digitalWrite(_pinClock, LOW);   // tick
    if (data & mask){               // choose bit
      digitalWrite(_pinData, HIGH); // set 1
    }else{
      digitalWrite(_pinData, LOW);  // set 0
    }
    digitalWrite(_pinClock, HIGH);  // tock
    --i;                            // move to lesser bit
  }
}

// sets register to a byte value for all screens
void Matrix::setRegister(uint8_t reg, uint8_t data)
{
  digitalWrite(_pinLoad, LOW); // begin
  for(uint8_t i = 0; i < _screens; ++i){
    putByte(reg);  // specify register
    putByte(data); // send data
  }
  digitalWrite(_pinLoad, HIGH);  // latch in data
  digitalWrite(_pinLoad, LOW); // end
}

// syncs row of display with buffer
void Matrix::syncRow(uint8_t row)
{
  if (!_buffer) return;
  
  // uint8_t's can't be negative, so don't test for negative row
  if (row >= 8) return;
  digitalWrite(_pinLoad, LOW); // begin
  for(uint8_t i = 0; i < _screens; ++i){
    putByte(8 - row);                // specify register
    putByte(_buffer[row + (8 * i)]); // send data
  }
  digitalWrite(_pinLoad, HIGH);  // latch in data
  digitalWrite(_pinLoad, LOW); // end
}

/******************************************************************************
 * MAX7219 Configuration
 ******************************************************************************/

// sets how many digits are displayed
void Matrix::setScanLimit(uint8_t value)
{
  setRegister(REG_SCANLIMIT, value & 0x07);
}

// sets brightness of the display
void Matrix::setBrightness(uint8_t value)
{
  setRegister(REG_INTENSITY, value & 0x0F);
}

/******************************************************************************
 * Helper Functions
 ******************************************************************************/

void Matrix::buffer(uint8_t x, uint8_t y, uint8_t value)
{
  if (!_buffer) return;
  
  // uint8_t's can't be negative, so don't test for negative x and y.
  if (x >= _maximumX || y >= 8) return;

  uint8_t offset = x; // record x
  x %= 8;             // make x relative to a single matrix
  offset -= x;        // calculate buffer offset

  // wrap shift relative x for nexus module layout
  if (x == 0){
    x = 8;
  }
  --x;

  // record value in buffer
  if(value){
    _buffer[y + offset] |= 0x01 << x;
  }else{
    _buffer[y + offset] &= ~(0x01 << x);
  }
}

/******************************************************************************
 * User API
 ******************************************************************************/

// buffers and writes to screen
void Matrix::write(uint8_t x, uint8_t y, uint8_t value)
{
  buffer(x, y, value);
  
  // update affected row
  syncRow(y);
}

void Matrix::write(uint8_t x, uint8_t y, Sprite sprite)
{
  for (uint8_t i = 0; i < sprite.height(); i++){
    for (uint8_t j = 0; j < sprite.width(); j++)
      buffer(x + j, y + i, sprite.read(j, i));
      
    syncRow(y + i);
  }
}

// clears screens and buffers
void Matrix::clear(void)
{
  if (!_buffer) return;

  // clear buffer
  for(uint8_t i = 0; i < 8; ++i){
    for(uint8_t j = 0; j < _screens; ++j){
      _buffer[i + (8 * j)] = 0x00;
    }
  }

  // clear registers
  for(uint8_t i = 0; i < 8; ++i){
    syncRow(i);
  }
}


De Library Matrix.h ziet er als volgt uit:

Code:
/*
  Matrix.h - Max7219 LED Matrix library for Arduino & Wiring
  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef Matrix_h
#define Matrix_h

#include <inttypes.h>

class Sprite;

class Matrix
{
  private:
    uint8_t _pinData;
    uint8_t _pinClock;
    uint8_t _pinLoad;

    uint8_t* _buffer;
    uint8_t _screens;
    uint8_t _maximumX;

    void putByte(uint8_t);
    void setRegister(uint8_t, uint8_t);
    void syncRow(uint8_t);

    void setScanLimit(uint8_t);

    void buffer(uint8_t, uint8_t, uint8_t);
  public:
    Matrix(uint8_t, uint8_t, uint8_t, uint8_t = 1);
    void setBrightness(uint8_t);
    void write(uint8_t, uint8_t, uint8_t);
    void write(uint8_t, uint8_t, Sprite);
    void clear(void);
};

#endif


Ondanks een sketch en Library vanaf de doorverwezen link , vanuit het cookbook komen er nog steeds foutmeldingen ??

Weet iemand mischien wat er hier mis gaat ??

Alvast bedankt voor het lezen,

ArduinoPat
27  International / Nederlands / ++ OPGELOST ++ Scroll text met PCF8574A I2C on: December 16, 2012, 12:52:40 pm
Hoi Rob,

Helemaal super , dit blijkt te werken !!!   smiley-grin

Many thanks ,

Sorry voor late reply ,

Fijne dagen toegewenst en een prettige jaarwisseling voor 2013

Groet,

Patrick, ArduinoPat, Maarssen
28  International / Nederlands / Re: Scroll text met PCF8574A I2C on: December 01, 2012, 04:19:04 pm
Goedenavond Rob,

Helaas gaat dit ook niet lukken  smiley-mad
Nu laat die de vaste tekst staan op rij 1 , en zie ik in rij 2 nu in het eerste blok steeds 1 letter weergeven ( van mijn scrolltext )


Ik denk wat ik wil niet gaat lukken ,

Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

const int numRows = 2;
const int numCols = 16;

const char textString[] = "                  * ArduinoPat *        ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Vaste Tekst");
}

void loop()
{
    for (int position = 0; position  < textLen; position++)
    {
      lcd.setCursor(0,1);  // of moet dit zijn 1,0?
      lcd.print(textString[position]);
      delay(150);
    }
    for (int position = textLen; position  >0; position--)
    {
      lcd.setCursor(0,1);
      lcd.print(textString[position]);
      delay(150);
    }
}


Maar voor als nog hartelijk dank voor jou input !!
29  International / Nederlands / Re: Scroll text met PCF8574A I2C on: December 01, 2012, 03:28:47 pm
Beste JO3RI,

Dit gaat helaas niet op , beide teksten scrollen ook met deze code ??
Ik heb al van alles geprobeerd, maar ben er nog niet uit  smiley-mad

Code:
/*
  Scroll
  * this sketch scrolls text left when tilted
  * text scrolls right when not tilted.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins

const int numRows = 2;
const int numCols = 16;



const char textString[] = "                  * ArduinoPat *      ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x27,16,2);

void setup()
{
   lcd.init();
   lcd.backlight();
  // set up the LCD's number of columns and rows:
  lcd.setCursor(0, 1);
  lcd.print(textString);
 
  lcd.setCursor(0, 0);
  lcd.print("Vaste Tekst");
}

void loop()
{
  {
    // here if tilted left so scroll text left
   
    for (int position = 0; position  < textLen; position++)
    {
     
      lcd.scrollDisplayLeft();
      delay(150);
    }
  }
 
  {
    // here if previously tilted but now flat, so scroll text right
   
    for (int position = 0; position  < textLen; position++)
    {
     
      lcd.scrollDisplayRight();
      delay(150);
    }
  }
}
     
   

Misschien iemnand nog een optie ??
30  International / Nederlands / ++OPGELOST ++ Scroll text met PCF8574A I2C on: November 17, 2012, 04:03:49 pm
Hallo Allen,

Ik probeer hem eens op het NL-Forum,

Ik ben bezig met een I2c schakeling , wat nu werkt,
De LCD gekoppeld aan een PCF8574A ,
Nu heb ik in ROW 1 een scrollende text , dit werkt goed.
Maar wil een vaste text in ROW 2  , dit werkt dus niet , deze scrollt namelijk ook mee wat dus niet de bedoeling is.

Dit is mijn setup:




En dit is mijn Sketch:


Code:
/*
  Scroll
  * this sketch scrolls text left when tilted
  * text scrolls right when not tilted.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins

const int numRows = 2;
const int numCols = 16;



const char textString[] = "                  * ArduinoPat *      ";
const int textLen = sizeof(textString) -1; // the number of characters

LiquidCrystal_I2C lcd(0x38,16,2);

void setup()
{
   lcd.init();
   lcd.backlight();
  // set up the LCD's number of columns and rows:
  
  lcd.print(textString);
}

void loop()
{
  {
    // here if tilted left so scroll text left
  
    for (int position = 0; position  < textLen; position++)
    {
      lcd.scrollDisplayLeft();
      delay(150);
    }
  }
 
  {
    // here if previously tilted but now flat, so scroll text right
    
    for (int position = 0; position  < textLen; position++)
    {
      lcd.scrollDisplayRight();
      delay(150);
    }
  }
}
      
    


Ik hoop dat iemand mij hiermee op weg kan helpen,

Alvast bedankt,

ArduinoPat
Pages: 1 [2] 3 4