led blinking

Discussion in 'Homework Help' started by kooldude, Dec 4, 2018.

  1. kooldude

    Thread Starter New Member

    Feb 15, 2018
    18
    2
    Hi is anyone is having answer for these questions.
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,704
    You are the one that should have the answers since this is homework.


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

    Thread Starter New Member

    Feb 15, 2018
    18
    2
    if i would have done it then why i would have asked you
     
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,704

    Do you always expect others to do your work for you? That is LAZY. If others do it for you then you learn nothing. Bet your instructor would be very interested in your attitude about learning.
     
    djsfantasi and dl324 like this.
  5. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,319
    2,009
    Because having someone do your homework for you would be cheating.
     
    djsfantasi and spinnaker like this.
  6. ScottWang

    Moderator

    Aug 23, 2012
    6,679
    1,029
    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.
     
  7. kooldude

    Thread Starter New Member

    Feb 15, 2018
    18
    2
    ok sorry guyz if might my words got misunderstood i have done some work on this just i want to know is it correct or not.I will share with you asap.
     
    absf and ScottWang like this.
  8. kooldude

    Thread Starter New Member

    Feb 15, 2018
    18
    2
    #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
     
  9. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,319
    2,009
    Your code would be easier to read with code tags:
    Code (Text):
    1. #include<stdio.h>
    2. void setup() {
    3.   //nested loop to initialize all the pins
    4.   int n;
    5.   for (int i = 0; i < 1; i++) {
    6.     for (int j = n; j > 0; j--) {
    7.       pinMode(pinMatrix[j], OUTPUT);
    8.     }
    9.   }
    10. }
    11. void loop() {
    12.   //nested loop which will turn each LED on and off in sequence
    13.   for (int i = 0; i < 1; i++) {
    14.     for (int j = n; j > 0; j--) {
    15.       digitalWrite(pinMatrix[j], HIGH);
    16.     }
    17.   }
    18. }
    Doesn't look like it oscillates to me meaning of oscillate is unclear.
     
  10. kooldude

    Thread Starter New Member

    Feb 15, 2018
    18
    2
    where pin matrix is written after that i is missing..
     
  11. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,319
    2,009
    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.
     
Loading...