readPin question
fearnot
Posts: 13
For some reason, I can write to pin using CPU.writePin but can't read it correctly. For basic test, I simply gave 5V DC to pin0 with 1k resistor with the following code
import stamp.core.*;
public class Test{
· public static void main(){
· int count = 30;
··· while (count > 0){
····· if (CPU.readPin(0) == true){
······· System.out.println("pin 0 is true");
····· }else {
··············· System.out.println("Pin 0 is false");
··········· }
····· CPU.delay(10000);
····· count--;
··· }
· }
}
and I get "pin 0 is false" all the time even though it is getting 5 volts straight out of battery. Any help please?
import stamp.core.*;
public class Test{
· public static void main(){
· int count = 30;
··· while (count > 0){
····· if (CPU.readPin(0) == true){
······· System.out.println("pin 0 is true");
····· }else {
··············· System.out.println("Pin 0 is false");
··········· }
····· CPU.delay(10000);
····· count--;
··· }
· }
}
and I get "pin 0 is false" all the time even though it is getting 5 volts straight out of battery. Any help please?
Comments
regards peter