Problems with simple allocation

30 Apr 2011

Hello, and sorry for my childish English. I get some errors by simplest things.

#include "mbed.h"

I2C i2c(p28, p27);        // sda, scl


int addr = 0x46;// 0x46; // define the I2C Address
DigitalOut mcp_reset(p19);
DigitalOut myled(LED1);
DigitalOut blink(LED2);

blink = 1;
myled = 0;
mcp_reset = 1;

int main() {
    char cmd[2];
    //mcp_reset = 1;
    while(1) {
        cmd[0] = 0x0A;            // pointer to command register
        cmd[1] = 0xFF;           // Start ranging, results in cm
        
      
       i2c.write(addr, cmd, 2); // Send command string
       
        wait(0.07);              // Could also poll, 65ms is typical
    }
}

The Compiler says myled, blink and mcp_reset has already been defined and has no storage class or specifier.

Whats the problem or am i only stupid?

30 Apr 2011

Assign values within main(). Compiler assumes you are defining variables.

<<code>>

  1. include "mbed.h"

I2C i2c(p28, p27); sda, scl

int addr = 0x46; 0x46; define the I2C Address DigitalOut mcp_reset(p19); DigitalOut myled(LED1); DigitalOut blink(LED2);

int main() { blink = 1; myled = 0; mcp_reset = 1;

....code

}