One Wire sketch doesn^t compile

Hi, everybody. I downloaded OneWire library v2.2 from Stoffregens page and installed. I have the following code but when I try to compile, ERROR. Cant figure out why?

#include <OneWire.h>

OneWire ds(12); // ERROR: OneWire does not name a type
byte addr[8];
int but[6] = { 0,149,107,48,13,0};
String keyStatus="";

void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}

void loop()
{
getKeyCode();

Serial.println("");
if(keyStatus==“ok”)
{
byte i;
for( i = 5; i >0; i–)
{
Serial.print(" : ");
Serial.print(addr*, DEC);*

  • }*
  • if(addr[1] == but[1] && addr[2] == but[2] && addr[3] == but[3] && addr[4] == but[4])*
  • {*
  • digitalWrite(13, HIGH);*
  • delay(500);*
  • digitalWrite(13, LOW);*
  • }*
  • else*
  • {*
  • digitalWrite(13, LOW);*
  • }*
  • }*
  • else if (keyStatus!="")*
  • {*
  • Serial.print(keyStatus);*
  • }*
  • delay(1000);*
    }
    void getKeyCode()
    {
  • byte present = 0;*
  • byte data[12];*
  • keyStatus="";*
  • if ( !ds.search(addr))*
  • {*
  • ds.reset_search();*
  • return;*
  • }*
  • if ( OneWire::crc8( addr, 7) != addr[7])*
  • {*
  • keyStatus=“CRC invalid”;*
  • return;*
  • }*
  • if ( addr[0] != 0x01)*
  • {*
  • keyStatus=“not DS1990A”;*
  • return;*
  • }*
  • keyStatus=“ok”;*
  • ds.reset();*
    }

Looks like the library is in the wrong place. If you only recently installed it and you are sure it is in the right place, i.e. beside all the other ones, your likely problem is that the IDE doesn't know about it yet. Restart the IDE so it can have a sniff around.

Does your code REALLY look like that? I seriously doubt it. Go read the posts at the top of the forum that you were supposed to read before you blundered in here. Post your code correctly.

Where did you download the library? A link, properly posted, not some vague handwaving will get you answers.

Where did you install the library?

What board are you compiling for? What operating system are you using? What version of the IDE?

OneWire ds(12); // ERROR: OneWire does not name a type

999 times out of 1000, this means that you did not download or install the library properly.