Go Down

Topic: [SOLVED] Issues with Arduino 1.0 (Read 860 times) previous topic - next topic


Feb 25, 2012, 03:00 pm Last Edit: Feb 25, 2012, 03:32 pm by kustom Reason: 1
At first I thought there was something wrong with my code, but then I've tried to compile and upload it using Arduino 0022 and it works. Here is my problem:

I'm breaking my code down to libraries so that it's easier to read. Right now I'm on shifting in.

So, here are relevant parts of code:


Code: [Select]
#include <ShiftRegisterDataCollect.h>

//number of shift registers

//shift register pins
#define CLOCK_PIN 7
#define LATCH_PIN 8
#define DATA_PIN 9

//for loop
int i = 0;

//Define variables to hold the data for each shift register.
byte switchVar[NUMBER_OF_SHIFT_REGISTERS] = {0};


ShiftRegisterDataCollect shiftData(LATCH_PIN, CLOCK_PIN, DATA_PIN);

void setup() {
 //start serial


void loop() {
 for (i=0; i<NUMBER_OF_SHIFT_REGISTERS; i++)  {
   switchVar[i] = shiftData.shiftInFunc();
   Serial.println(switchVar[i], BIN);


Code: [Select]
#ifndef ShiftRegisterDataCollect_h
#define ShiftRegisterDataCollect_h

#include "WProgram.h"

class ShiftRegisterDataCollect  {

       ShiftRegisterDataCollect(int latchPin, int clockPin, int dataPin);
       byte shiftInFunc();
       void latchPinFunc();

       int _latchPin, _dataPin, _clockPin;




Code: [Select]
#include "WProgram.h"
#include "ShiftRegisterDataCollect.h"

ShiftRegisterDataCollect::ShiftRegisterDataCollect(int latchPin, int clockPin, int dataPin) {

  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, INPUT);

 _latchPin = latchPin;
 _clockPin = clockPin;
 _dataPin = dataPin;

byte ShiftRegisterDataCollect::shiftInFunc() {

   int i;
   int temp = 0;
   int pinState;
   byte myDataIn = 0;

 for (i=7; i>=0; i--)  {

   digitalWrite(_clockPin, 0);
   temp = digitalRead(_dataPin);

   if (temp) {
     pinState = 1;
     //set the bit to 0 no matter what
     myDataIn = myDataIn | (1 << i);

   else {
     //turn it off -- only necessary for debuging
    //print statement since myDataIn starts as 0
     pinState = 0;

   digitalWrite(_clockPin, 1);

 return myDataIn;


Errors I'm getting using v1.0:

The code compiles and runs just fine using 0022 so I'm guessing it's some weird bug or something in 1.0.


You haven't read the release notes for 1.0   

WProgram.h is now Arduino.h
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


Add a file to C:\{path to arduino}\arduino-1.0\hardware\arduino\cores\arduino called WProgram.h - edit it and add the line : #include <Arduino.h>

That should clear that up for you.
http://www.uk-pcb.co.uk - UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details. Arduino & C# PC programming.


Ah okay. It works just fine now. Thanks.

Go Up