nap mode problem and changing variable question
I have found that everytime I use the·nap mode; it freezes my microcontroller.· i've tried the basic code that's in the user manuel.
System.out.println("Time to take about a 2-second nap");
CPU.nap(7);············ // i've tried changing between 0 and 7
System.out.println("Nap Completed");
Is my microcontroller damaged?
I'm also having trouble trying to use the following code.·
·for (int i =0; i < headb.length(); i++)
· {
··· motor.turnHeadb + i + (); headb[noparse][[/noparse]i] = ping.getIn();···· //right to left
· }
·
I'm trying to make this code loop through
motor. turnHeadb0();· headb[noparse][[/noparse]0]= ping.getIn();
motor. turnHeadb1();· headb[noparse][[/noparse]1]= ping.getIn();
motor. turnHeadb2();· headb[noparse][[/noparse]2]= ping.getIn();
motor. turnHeadb3();· headb[noparse][[/noparse]3]= ping.getIn();
motor. turnHeadb4();· headb[noparse][[/noparse]4]= ping.getIn();
The problem is in the first part trying to make the object motor go to the correct method.
This is probably a stupid question. Any help would be appreciated.
thanks,
Brian
System.out.println("Time to take about a 2-second nap");
CPU.nap(7);············ // i've tried changing between 0 and 7
System.out.println("Nap Completed");
Is my microcontroller damaged?
I'm also having trouble trying to use the following code.·
·for (int i =0; i < headb.length(); i++)
· {
··· motor.turnHeadb + i + (); headb[noparse][[/noparse]i] = ping.getIn();···· //right to left
· }
·
I'm trying to make this code loop through
motor. turnHeadb0();· headb[noparse][[/noparse]0]= ping.getIn();
motor. turnHeadb1();· headb[noparse][[/noparse]1]= ping.getIn();
motor. turnHeadb2();· headb[noparse][[/noparse]2]= ping.getIn();
motor. turnHeadb3();· headb[noparse][[/noparse]3]= ping.getIn();
motor. turnHeadb4();· headb[noparse][[/noparse]4]= ping.getIn();
The problem is in the first part trying to make the object motor go to the correct method.
This is probably a stupid question. Any help would be appreciated.
thanks,
Brian
Comments
I have had that same experience and never got it to work.
for (int i =0; i<5; i++) {
·· switch·(i) {
····· case 0: motor. turnHeadb0();
················ break;
····· case 1: motor. turnHeadb1();
················ break;
····· case 2: motor. turnHeadb2();
················ break;
····· case 3: motor. turnHeadb3();
················ break;
····· case 4: motor. turnHeadb4();
················ break;
····· default:
· }
· headb[noparse][[/noparse]i]= ping.getIn();
}
If you·can make headb(int index), then the above code
simplifies·to
for (int i =0; i<5; i++) {
··turnHeadb(i);
· headb[noparse][[/noparse]i]= ping.getIn();
}
·
regards peter
The second part of your code is more like what I was looking for; I like my mainclasses text to be short.
thanks,
Brian