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.
9 years, 5 months ago.
Counter, and how to make a variable
This is how my code look like
- include "mbed.h"
DigitalOut myled1(p25);
DigitalOut myled2(p28);
DigitalOut myled3(p29);
DigitalIn button1(p30);
DigitalOut buttonout(p7);
- 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, 5 months 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/