9 years, 1 month ago.

Counter, and how to make a variable

This is how my code look like

  1. include "mbed.h"

DigitalOut myled1(p25);

DigitalOut myled2(p28);

DigitalOut myled3(p29);

DigitalIn button1(p30);

DigitalOut buttonout(p7);

  1. define buttongo

int counter = 0;

int main(){

counter++;

if (counter == 4){

counter = 1;

} myled[counter.int] = 1; }

I wonder how I could make the counter be able to chose wich pins that is going to be used. earlier I coded in python and basic stamp, so I am new here : P And yeah, how do I make it look like a code in question site?

1 Answer

9 years, 1 month ago.

a simple search " array led" in this site provides a answer:
https://developer.mbed.org/users/jsbosch/notebook/array-of-digitalout-objects/
To learn c++ look at this "gold" site :http://www.cplusplus.com/