Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 7 months ago.
Coding for LED and Photo diodes with digital inputs and outputs.
I want to incorporate 6 LEDs and Photodoide but im getting errors with two inputs, how can i fix this. How can i fix this? no operator = matches these operands
- include "mbed.h"
DigitalOut LED_1(PTC0); DigitalIn photo_1(PTB3);
DigitalIn LED_2(PTC7); DigitalOut photo_2(PTB2);
DigitalIn LED_3(PTC3); DigitalOut photo_3(PTB1);
DigitalIn LED_4(PTC4); DigitalOut photo_4(PTB0);
DigitalIn LED_5(PTC5); DigitalOut photo_5(PTB8);
DigitalIn LED_6(PTC6); DigitalOut photo_6(PTB9);
Serial pc(USBTX, USBRX);
int input_1; int output_1;
int input_2; int output_2;
int input_3; int output_3;
int input_4; int output_4;
int input_5; int output_5;
int input_6; int output_6;
int main() {
LED_1 = 0; LED_2 = 0; LED_3 = 0; LED_4 = 0; LED_5 = 0; LED_6 = 0;
while(1) { input_1 = photo_1.read(); input_2 = photo_2.read(); input_3 = photo_3.read(); input_4 = photo_4.read(); input_5 = photo_5.read(); input_6 = photo_6.read();
if(input_1&&input_2){ LED_1 = 1; output_1 = 1; LED_2 = 1; output_2 = 1;
if(input_3){ led_3 = 1; output_3 = 1;
if(input_4){ led_4 = 1; output_4 = 1; } if(input_5){ led_5 = 1; output_5 = 1; } if(input_6){ led_6 = 1; output_6 = 1; } else LED_1 = 0; output_1 = 0;
LED_2 = 0; output_2 = 0;
LED_3 = 0; output_3 = 0;
LED_4 = 0; output_4 = 0;
LED_5 = 0; output_5 = 0;
LED_6 = 0; output_6 = 0; } pc.printf("photo: %d, led: %d\r\n",input_1,output_1);
pc.printf("photo: %d, led: %d\r\n",input_2,output_2);
pc.printf("photo: %d, led: %d\r\n",input_3,output_3);
pc.printf("photo: %d, led: %d\r\n",input_4,output_4);
pc.printf("photo: %d, led: %d\r\n",input_5,output_5);
pc.printf("photo: %d, led: %d\r\n",input_6,output_6);
wait(.5);
}
Please edit the post to use
so that the formatting is preserved otherwise it's hard to tell what's a comment and what isn't.
And please give every possible detail of the error you get rather than just the type of error. The compiler gives you a line number, it would be helpful if you told us that.
posted by Andy A 28 Apr 2017