Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Homework Help/Study Tips Expert

A description of each function used in the program.

Theree programs:

/* HiTechnic Experimenter''s Kit Program

Experiment - 6 Reaction Time Measurement

This program measures the time taken to press a button switch after an LED is turned on.

(c) HiTechnic 2009

*/
#include "NXCDefs.h"

#define PROTO_PORT IN_1

int currtime;
int deltatime;
int randomtime;
int inputdata;
int outputdata;
int count;
byte cmndbuf[]; // buffer for outbound I2C command
byte respbuf[]; // buffer for inbound I2C response

/* protoboard I/O map
42,43 - A0 input
44,45 - A1 input
46,47 - A2 input
48,49 - A3 input
4A,4B - A4 input
4C - B inputs
4D - B outputs
4E - B controls
*/

void readdata()
{
ArrayInit(cmndbuf, 0, 2); // set the buffer to hold 2 values
cmndbuf[0] = 0x02; // set write to channel
cmndbuf[1] = 0x4C; // to set read address
count=1; // 1 byte to read
I2CBytes(PROTO_PORT, cmndbuf, count, respbuf); // issue I2C write command and read the byte back
inputdata=respbuf[0]&0x03;
}

void writedata()
{
ArrayInit(cmndbuf, 0, 3); // set the buffer to hold 3 values
cmndbuf[0] = 0x02; // set write to channel
cmndbuf[1] = 0x4D; // to set write address
cmndbuf[2] = outputdata; // to set write data
count=0; // no bytes to read
I2CBytes(PROTO_PORT, cmndbuf, count, respbuf); // issue I2C write command and read the byte back
}

task main()
{
SetSensorLowspeed(PROTO_PORT); // set sensor port 1 to low speed serial (I2C)
Wait(100);

ArrayInit(cmndbuf, 0, 3); // set the buffer to hold 3 values
cmndbuf[0] = 0x02; // set write to channel
cmndbuf[1] = 0x4E; // to set write address
cmndbuf[2] = 0x30; // to write 001111
count=0; // no bytes to read
I2CBytes(PROTO_PORT, cmndbuf, count, respbuf); // issue I2C write command
Wait(100);

while (TRUE)
{
outputdata=0;
writedata();
ClearScreen();
TextOut(20, LCD_LINE2, "running");
randomtime=Random(5000)+5000;
Wait(randomtime);

outputdata=0x10;
writedata();
currtime=CurrentTick();

inputdata=0x00;
while(inputdata!=0x01)
{
readdata();
}
deltatime=CurrentTick()-currtime;
ClearScreen();
NumOut(20, LCD_LINE2, deltatime);

inputdata=0x00;
while(inputdata!=0x03)
{
readdata();
}
}
}

Homework Help/Study Tips, Others

  • Category:- Homework Help/Study Tips
  • Reference No.:- M9502332

Have any Question?


Related Questions in Homework Help/Study Tips

Comments 1 the first thing the researcher needs to do

Comments: 1. The first thing the researcher needs to do before organizing his/her qualitative data is to determine which sources of information will be used in their literature review. One reliable source of information ...

Question everyone has the capacity for creative expression

Question: Everyone has the capacity for creative expression. Poetry/spoken word is creative arts therapy tool which creates a tangible links between individuals and the environment around us. Exercise: Think and reflect ...

1 you also discover that your firm conducted some

1. You also discover that your firm conducted some consultancy services for "BMC" in that they performed a review of the internal control procedures for Accounts Payable and Receivable and also used your firm's recruitme ...

Question read the article titled securing the cloud for the

Question: Read the article titled "Securing the Cloud for the Enterprise". What do YOU believe to be the two (2) most important security considerations related to cloud deployments, and explain the main reasons why you b ...

Question journalfor this journal entry recommend a health

Question: Journal For this Journal entry, recommend a health care reform policy alternative to positively impact insurance coverage and financing the delivery of healthcare in this country. Journal entry should be at lea ...

The visual system has specialized areas for perceiving

The visual system has specialized areas for perceiving faces, bodies, and places, but not other kinds of objects. Why do you think we have specialized areas for these functions but not others? What scripture could I use ...

Question you all work in or know of people who work in

Question: You all work in or know of people who work in enterprise IT environments Maintaining the enterprise security posture, legal risk, and security is constantly changing. What makes it so difficult to maintain info ...

Classical organizational theory deals with the systematic

Classical Organizational Theory deals with the "systematic processes necessary to make bureaucracy more efficient and effective." Two scholars (Weber and Taylor) are credited with the development of classical organizatio ...

Case emanuel medical center crisis in the health care

Case: Emanuel Medical Center: Crisis In The Health Care Industry By Randall Harris, Kevin Vogt, And Armand Gilinsky Now that you have selected and carefully reviewed your case study, it is time to begin analyzing the sit ...

Discussion 1 patient safety actread the patient safety and

Discussion 1: Patient Safety Act Read the Patient Safety and Quality Improvement Act of 2005. Then, review the information on the Core Measure Sets from The Joint Commission. Pick one of the core measures from the list o ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As