Question:
can anyone help me with writing matlab code for this arduino program ?
Nobody
2013-04-18 10:56:45 UTC
void setup ()

{
pinMode(11,OUTPUT);

pinMode(12,OUTPUT);

pinMode(13,OUTPUT);

}

void loop()

{

digitalWrite(11,HIGH);

digitalWrite(12,LOW);

digitalWrite(13,LOW);

delay(1000);

digitalWrite(12,HIGH);

digitalWrite(11,LOW);

digitalWrite(13,LOW);

delay(1000);

digitalWrite(13,HIGH);

digitalWrite(11,LOW);

digitalWrite(12,LOW);

delay(1000 );

}
Three answers:
Greywolf
2013-04-19 09:35:43 UTC
Here's the page that explains MATLAB on Arduino http://playground.arduino.cc/Interfacing/Matlab
2013-12-04 10:36:08 UTC
This program will count from 50 in increments of 10 every

250 milliseconds until it reaches 590 and then it will decrease

in increments of 5 every 100 milliseconds until it reaches 50.

When the counter is greater than 450, it will turn an LED on.

**************************************************************/



int counter = 50; // declares "counter" to have a value of 50

int LEDpin = 13; // LED is in pin 13



void setup()

{

pinMode(LEDpin, OUTPUT); //declares output for the built-in LED in pin 13

Serial.begin(9600); //starts the serial monitor

delay(10); //gives serial monitor time to attach all necessary code

Serial.println(""); //allows every printed line to be in same column

}



void loop()

{

counter = 50; //sets counter back to 50



while(counter < 590) //declares a condition that when the "counter" is less than 590 it will perform what's in the loop

{



if(counter > 450) // when the counter is greater than 450, it will turn the LED on

digitalWrite(LEDpin, HIGH); //turns LED on

else

digitalWrite(LEDpin, LOW); //turns LED off





Serial.print("The current value is "); //prints what is in quotes in the serial monitor

Serial.println(counter); //prints the value of "counter" in serial monitor on same line as previously printed line

delay(250); // prints the lines being printed every 250 milliseconds

counter+=10; // increments counter by 10

}



while (counter > 50)

{

if(counter > 450)

digitalWrite(LEDpin, HIGH);

else

digitalWrite(LEDpin, LOW);



Serial.print("The current value is ");

Serial.println(counter);

delay(100);

counter-=5;

}

}
odonovan
2016-08-10 07:16:48 UTC
There is no technique to "dim" an LED. You are proper by saying make it flicker. The human eye can perceive about 50Hz. So are attempting try turning the LED on and off below 50Hz and up larger. You're going to detect the LED appears to be dimming and brightening considering that the human eye cannot perceive such quick blinks. So far as the Arduino code i'm of now support, but expectantly that is enough to aid you some.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...