Yes to everything. The analog pins work as digital, if you address them as 14, 15 ..., ie digitalWrite(14) will output on analog 0. (Remember to set pinMode() first, of course)
pin 0 and 1 work fine as digital pins ... as long as you do not use the USB or Serial stuff. Usually they are not used as plain digital pins.
" i cant seem to get is to work" does not say what does not work. Do the motors not turn at all? Or do they turn to fast/wrong way or what?
Your subject mentions "Motor shield". How have you verified that the wiring is correct? - perhaps including a schematic here might help resolve the problem.
Spark Fun Electronics 1.0" Single Digit Alphanumeric Display - Green/Yellow x1 5-way Tactile Switch x2 N-Channel MOSFET 60V 30A x10 MOSFET Power Control Kit x3
The switch and display is just for fun, The switch is SMD - didnt expect that - but here is a test
The MOSFETs (RFP30N06LE) are GREAT! I had a problem to control high Amp load with MOSFETS (getting a high enough gate voltage) but these MOSFETs turn fully on at Arduinos 5V output. My local (web-)stores dont carry them, so I previously used others, less well suited ones. Maybe I buy a 100 and sell them
You need to set it as an output though or it's not properly turned on.
Well, there you go. All this chit chat and yet, another interesting fact creeps up. I thought from this (and some other stuff done previously) that all pins start as INPUT (re)boot, except #13 because of its LED wiring basically only is usable as OUTPUT.
Hmmm. digitalWrite to an input pin is supposed to put a 20K resistor to Vcc and if the other end of the LED is at GND then yes, I get 0.2mA through the LED. It glows a lot brighter than that. <Gets out the DVM> And measures 4.8V ... So I tried different INPUT, OUTPUT LOW and HIGH, and yes: With INPUT the 20K pullup just barley makes the onboard LED glow. It has to be OUTPUT. And that is what pin 13 is, by default. I think I am right here. Oh well, we could look at the init code at github, but I cant be bothered now.
Constructive critism is always welcome. If the worst happens I learn someting.
plese help me. Here not mistake, bet do not work good.
void loop() {
if (digitalRead(switchPin) == HIGH) { // If switch is ON, Serial.print(1, BYTE); // send 1 to Processing } else { // If the switch is not ON, Serial.print(0, BYTE); // send 0 to Processing } delay(100); }
if (digitalRead(ZZZZ) == HIGH) { // If switch is ON, Serial.print(2, BYTE); // send 2 to Processing } else { // If the switch is not ON, Serial.print(0, BYTE); // send 0 to Processing } // delay(100); // Wait 100 milliseconds
Bad English is excusable, I can understand despite numerous spelling mistakes, wrong grammer and worse.
It is that you still have not said what it is that does not work. You expect me (or other Forum users), from the program and your cryptic "bet do not work good" to guess what you are expecting to happen, from what I can derive that the program actually does (and that is not always easy). In this case, is it showing the wrong colurs on your Processing or too briefly? Are your buttons something that is held down a long time or something that happens very quickly?
(1) What are you doing (2) What are wanting to happen (3) what is actually happening
Well, just because ... and for no particular reason at all, and the "cheering up" by the link of AWOL <shudder>, I now did test it. With the correction pointed out by CrossRoads, and the strange stuff (--> ) that bld mentions ... the correct program. It does turn on the onboard LED!!!!!!!!!!!!!!!!!!!!!! (damn, that sticky Shift-1 key)
Code:
/* Lighting a LED */ #define LED_dig1 10 #define LED_dig2 3 int LED_pin = LED_dig1+LED_dig2 ;
void setup() { Serial.begin(9600) ; int LED_Mode ; LED_Mode=OUTPUT ; pinMode(LED_pin,LED_Mode) ; if (LED_Mode == OUTPUT) Serial.println("LED mode set correct") ; }
void loop () { if (LED_pin==13) { // check we are using the right pin digitalWrite(LED_dig1+LED_dig2,!digitalRead(13)) ; } }
A resistor does not "smooth" a fluctating voltage. A resistor-Capacitor circuit will do so.
IF (I am making assumptions here) the voltage meter is showing a steady voltage, and the Arduino is showing erratic values I can think of two possible causes: You ar not using the right pins (and the program is reporting an opencircuit/nonsense value) or your physical construction of the circuit is not solid enough, there is a loose connection.
We might get this kind of problem if the sensor is not outputting a single steady voltage level, but some pulsetrain or there is some other "noise" on the line. The voltage meter takes long samples, ie. it sort of shows an average voltage level. The Arduino ADC is a lot faster and might truly sample the voltage. Only way to know is to use an oscilloscope. (Or use an RC circuit...but then we move into a whole new set of problems)
Could you get your friend to write a little/short description of how/what his sensor is doing, which you then include here?
(NB: Have you tried the Scandianvian Forum where you can write in Finnish?)
It is always instructive to see the other posts made by a person asking... So, I gather you finally have gotten the Processing/Arduino distiction sorted out (earlier thread)
Lets see what you are doing. The Arduino code is sending two bytes roughly ten times a second. It can be sending 00, 10, 02 or 12 depending on the state of the switches.
The Processing colours a rectangle : IF "2" then white, if "1" then gray, else brown.
So.... if you only press one button on the Arduino then the other button's "0" signal will colour the rectangle ... (that is a hint)
Pleaseplease, when asking question make it clear which bit is not working. You may find - I have a few times - that explaining precisly what goes wrong, makes you find the error yourself (usually while writing the post, which then does not have to be sent )
EACH time you ask include three things: 1: What did you do?That is the code, the circuit diagram, what commands, button pushes you do. 2: What did you want to happen? (f.ex: The LED blinks 5 times at left button push; the LED turns Green on temperature exceeding 20C) 3: What actually did happen? (f.ex: The LED blinked once; The RGB-LED turn Yellow instead of Green at 20C and turned Green at 30C)
The advice is: "Get a job you love, and you won't have to work a single day in your life."
Deserves to be highlighted. It's what I did: choose to study exactly what I liked, got a series of jobs in the same field and after 40 years (really? that long already?) I still look forward to Monday.