Question

I'm trying to recreate an experiment from class but I'm missing some code. I need an...

I'm trying to recreate an experiment from class but I'm missing some code. I need an arduino uno program that will ask the user to enter a duty cycle and frequency, and to then generate a square pulse width (0-5V) based on those values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#define duty cycle
#define frequency

  
unsigned long duration = 0;
int rpmFactor = 100;
int convertedDuration;
unsigned long readTimeout = 10000;
int state=0;

void setup(){
pinMode(OUT_PIN, OUTPUT);
pinMode(IN_PIN, INPUT);
Serial.begin(9600);
}

void loop()
{
duration = pulseIn(IN_PIN, HIGH);
digitalWrite(OUT_PIN, !digitalRead(OUT_PIN));
delayMicroseconds(duration);
Serial.println(duration);
}


Interrupt

Code: [Select]

int pin = 0 to 5 v
volatile int state = LOW;

void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
Serial.begin(9600);
int state = 0;
}

void loop()
{
digitalWrite(pin, state);   
}

void blink()
{
state = !state;

Add a comment
Know the answer?
Add Answer to:
I'm trying to recreate an experiment from class but I'm missing some code. I need an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need some help on Java. I'm stuck on trying to generate a new string by...

    I need some help on Java. I'm stuck on trying to generate a new string by concatenating the reversed substrings of even indexes and odd indexes separately from a given string. I'm not sure how to figure this out. See example. Example: Input: abscacd Output: dasaccb Substrings: asad, bcc Reversed substrings: dasa, ccb.

  • Clock Divider ​​​​​​ can i get some simple explanation ( what I'm suppose to understand from this) my lecturer explains it but I honestly don't understand what statements he's trying to ma...

    Clock Divider ​​​​​​ can i get some simple explanation ( what I'm suppose to understand from this) my lecturer explains it but I honestly don't understand what statements he's trying to make my understanding : there's a frequency input of 512 Mhz, since we know 8 bit counter can count up to 256, it will do it once before it rolls overload (???) can someone please clarify and point out the important facts that i should be undertanding please and...

  • .Need code for my java class !! Write a simple java program that uses loops. You...

    .Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...

  • Clock Divider ​​​​​​ can i get some simple explanation ( what I'm suppose to understand from...

    Clock Divider ​​​​​​ can i get some simple explanation ( what I'm suppose to understand from this) my lecturer explains it but I honestly don't understand what statements he's trying to make my understanding : there's a frequency input of 512 Mhz, since we know 8 bit counter can count up to 256, it will do it once before it rolls overload (???) can someone please clarify and point out the important facts that i should be undertanding please and...

  • Use java (I already have some of the code just I'm not the best please help!)...

    Use java (I already have some of the code just I'm not the best please help!) Write a program that will ask the user to enter 5 quiz grades. Add each quiz grade to a double variable called quizTotals. Then, calculate the average of all 5 quiz grades, and store it in a double variable called quizAverage.. Display the following output to the user: Enter quiz grade #1: Enter quiz grade #2: Enter quiz grade #3: Enter quiz grade #4:...

  • Java, I need the code. Thank you Part B Create an Orders class that allows creating...

    Java, I need the code. Thank you Part B Create an Orders class that allows creating customers and managing their accounts. This class serves a client class for Customer (0.5 Points) Create two customers with your name and partner name, customer1 and customer2, customer2 should be assigned 20000 point. (1 Point) Ask the user to enter a bill amount for customer1 and invoke the method updateRewards to updated customer1 rewards points based on the enter bill_amount . (1 Point) Ask...

  • I need help making this work correctly. I'm trying to do an array but it is...

    I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...

  • I need a code that would give me the desired result (the ones in green) from...

    I need a code that would give me the desired result (the ones in green) from the input (in blue) im using c++. I'm so lost someone please help me. All I know is that there has to be a "while" loop and there is no need for "if" statements. 11. Examples of input and output Here are some examples of input and output for the above program code. Here is an example input from file input1.txt 6 inches 1.5...

  • I'm trying to construct this program in C#, I found some similiar problems in Java but...

    I'm trying to construct this program in C#, I found some similiar problems in Java but as a beginner, its not very easy to follow along with the Java code. Create a Console application named RelativesApp to help you remember your relatives’ birthdays. ·Create a Relative class that includes auto-implemented properties for the relative's name, their relationship to you, and two integers to represent their birthday –month, day. ·Declare an array of at least 12 relative objects. ·Fill the array...

  • Java Branches code not working please HELP!! I am trying to build this class that will...

    Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT