digitalToggle not working?

I tried the example cause i need to toggle outputs in my project:

/*

  • Description:
  • Flash an LED using the DigitalToggle library.
  • The digitalToggle() function toggles the state of the
  • specified digital output pin without needing to know the
  • current state of the pin. It does this by writing to the
  • PIN register instead of using digitalWrite() which uses
  • the PORT register.
  • The pin can be toggled by calling digitalWrite and
  • alternating the state of the pin. This produces an
  • output with a 7.4uS period, or ~135kHz and takes
  • 10 bytes per call (20 per toggle):
  • digitalWrite(ledPin,HIGH);
  • digitalWrite(ledPin,LOW);
  • The pin can be toggled by calling digitalToggle. This
  • produces an output with a 5.1uS period, or ~196kHz and
  • takes 8 bytes per toggle.
  • digitalToggle(ledPin);
  • The pin can be toggle by calling digitalToggleFast.
  • This produces an output with a 4.1uS period, or 244kHz
  • and takes 44 bytes per call.
  • digitalToggleFast(ledPin);

*/
#include <DigitalToggle.h>

int ledPin = 13;

void setup() {
pinMode(ledPin, OUTPUT);
}

void loop(){
delay(500);
digitalToggle(ledPin);
}

I get these errors:

C:\Users\Jan\Documents\Arduino\libraries\DigitalToggle\DigitalToggle.cpp: In function ‘void digitalToggle(uint8_t)’:
C:\Users\Jan\Documents\Arduino\libraries\DigitalToggle\DigitalToggle.cpp:25: error: ‘digitalPinToPort’ was not declared in this scope
C:\Users\Jan\Documents\Arduino\libraries\DigitalToggle\DigitalToggle.cpp:25: error: ‘portInputRegister’ was not declared in this scope
C:\Users\Jan\Documents\Arduino\libraries\DigitalToggle\DigitalToggle.cpp:25: error: ‘digitalPinToBitMask’ was not declared in this scope

Why is not working?

Best regards

Jan totally newb with one weeks experience;-)

#include <DigitalToggle.h>

Got a link to this library?

Has it been updated for post 1.0 use? The error messages indicate no.

You can find the info and download here:

http://playground.arduino.cc/Code/DigitalToggle

There is a comment : "note: I had to edit DigitalToggle.cpp and add an include of Arduino.h in order to get this to compile. --cellularmitosis 2012/11/3"

No idea what it means other than needs fixing;-)

No idea what it means other than needs fixing;-)

Is there some part of:

I had to edit DigitalToggle.cpp

that is hard to understand? Or, perhaps hard to do?

and add an include of Arduino.h

Seems pretty obvious to me.

Seems pretty obvious to me.

But certainly not to me ;)

This is the first contact i have had with the programming world....and this is why Arduino is so cool, no matter how little understanding i have, i can copy/paste and modify others work to something i can use :)

So if someone could explane how i do this?

best regards

Jan

The issue is that that library hasn’t been updated since 2009, and the Arduino system has been
changed a bit.

You need to find the DigitalToggle.h header file (your installed libraries are under the libraries
subdirectory of the sketchbook directory) and edit it:

change the line:

#include <pins_arduino.h>

to:

#include "Arduino.h"

Thank you Mark and Paul, that was easy if you know what to do ;)

No probelm with the switchToggle now...

I am impressed with this forum. Will sure be back with other "stupid" questions...

best regards

Jan