led blinking

spinnaker

Joined Oct 29, 2009
7,835
You are the one that should have the answers since this is homework.


Show what you have done and folks will try to help.
 

ScottWang

Joined Aug 23, 2012
6,883
if i would have done it then why i would have asked you
The rules in this forum is that the members can't provide the direct answer to the poster as you, and only could help you to get the answer step by step, otherwise the member who provide the direct answer will be prohibit to come to this Homework Help forum, setup the rules is for the students to learn how to solve the problems.

Please be polite to the helpers and don't ask them to break the rules.
 

Thread Starter

kooldude

Joined Feb 15, 2018
18
#include<stdio.h>

void setup() {


//nested loop to initialize all the pins

int n;


for(int i = 0; i < 1; i++){


for(int j = n; j >0; j--){


pinMode(pinMatrix[j], OUTPUT);


}


}


}


void loop() {


//nested loop which will turn each LED on and off in sequence


for(int i = 0; i <1; i++){


for(int j = n; j >0; j--){


digitalWrite(pinMatrix[j], HIGH);


}


}

this my solution please let me know if anything needs to be changed
 

dl324

Joined Mar 30, 2015
10,528
this my solution please let me know if anything needs to be changed
Your code would be easier to read with code tags:
Code:
#include<stdio.h>
void setup() {
  //nested loop to initialize all the pins
  int n;
  for (int i = 0; i < 1; i++) { 
    for (int j = n; j > 0; j--) {
      pinMode(pinMatrix[j], OUTPUT);
    }
  }
}
void loop() {
  //nested loop which will turn each LED on and off in sequence
  for (int i = 0; i < 1; i++) { 
    for (int j = n; j > 0; j--) {
      digitalWrite(pinMatrix[j], HIGH);
    }
  }
}
Doesn't look like it oscillates to me meaning of oscillate is unclear.
 

dl324

Joined Mar 30, 2015
10,528
where pin matrix is written after that i is missing..
You're missing a lot. The program as written won't compile and it wouldn't do anything without a main(). The loop function doesn't loop. The matrix size is undefined.

It's unclear from the problem description whether the pattern repeats when you get to the end or if it reverses when it gets to the end of the matrix.
 
Top