MODERATOR ACTION:
- Added relevant information on title
// generated by mBlock5 for <your product>
// codes make you happy
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
pinMode(3,OUTPUT);
while(1) {
digitalWrite(3,1);
_delay(float(random(1, 5 +1)));
digitalWrite(3,0);
_delay(float(random(1, 5 +1)));
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}
how do you get the read digital pin = 5? i can only get it to do belowThis will sound alarm for min 5 sec, after than stay off until alarm off button pushed.
View attachment 194372
Regards, Dana
im on the latest IDE 2.3.3Those are relatively standard includes, did you do the steps in post #40, reinstall Arduino IDE ? The newest version ?
By the way, when you do have the includes whats the very first error, copy and paste, you get ?
// generated by mBlock5 for <your product>
// codes make you happy
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
pinMode(9,OUTPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
// Alarm drive pin off when powered up
digitalWrite(9,0);
while(1) {
// Alarm input on pin high
if(digitalRead(5) == 1.000000){
_delay(0.5);
// Alarm input still on after .5 secs ? Then
// turn on alarm
if(digitalRead(5) == 1.000000){
digitalWrite(9,1);
// Alarm on for min of 5 sec
_delay(5);
}
}
// Alarm off pin high ?
if(digitalRead(6) == 1.000000){
_delay(0.5);
// Alarm off input still on after .5 secs ? If so turn it off
if(digitalRead(6) == 1.000000){
digitalWrite(9,0);
}
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}
void setup() {
pinMode(3,OUTPUT);
pinMode(4,INPUT);
digitalWrite(3,1);
while(1) {
if(digitalRead(4) == 1.000000){
digitalWrite(3,0);
}else{
digitalWrite(3,1);
}
}
}
I don´t see a dely at all ... What do you mean?there is a 2 second delay in this script i
so far so goodwhen you send pin 4 high it turns led off
Simple question: Did you set pin 4 to LOW??but take the high off pin 4 it takes 2 seconds before the led turns back on again
yes your right i didnt, but i just tried that then, 10k resistor to ground, it turned the led off when i put the resistor in without it even going high. wtf??Hi,
I don´t see a dely at all ... What do you mean?
thus I guess this is not a software problem at all, but a hardware problem..
so far so good
Simple question: Did you set pin 4 to LOW??
--> My guess: you did not, you just left pin 4 floating.
Floating menas undefined. It my be HIGH, it may be LOW, it may be inbetween, it may change, fast or slow. Indeed you don´t know.
If you want it to be LOW, you have to MAKE it LOW.
* Either the same way as you set it HIGH ...
* or by defualt by using a pull down resistor (maybe 10k is a good start)
yes i erased everything manually after uninstalling.Arduino pins on startup (and pullup effects) :
What is the default setting for a digital output pin
With digitalWrite(pin_number,value), we can set an output pin as HIGH or LOW. But if only coding pinMode (pin_number, OUTPUT), what is the default state for the pin pin_number, LOW or HIGH? It is n...arduino.stackexchange.com
I think one of the key issues I missed on install in prior posts one has to install the ATTINY core into IDE :
Install ATTINY Core on Arduino 2.3.2 (Windows 10 64bit)
Install ATTINY Core on Arduino 2.3.2 (Windows 10 64bit): The usualy method of installing ATtiny core using "http://drazzy.com/package_drazzy.com_index.json" can result the following error: Some indexes could not be updated. Get "https://drazzy.com/package_drazzy.com_index.json": tls: failed to...www.instructables.com
When you did the 2.3.3 install did you erase the prior installation left over folders ? Eg. post # 40 ?
im just giving up and deleting the includes.
Boards Manager Installation
This core can be installed using the boards manager. The boards manager URL is:
- File->Preferences on a PC, or Arduino->Preferences on a Mac, enter the above URL in "Additional Boards Manager URLs
- Tools -> Boards -> Boards Manager...
- Select "ATTinyCore by Spence Konde" and click "Install".
now that works all ok, everything compiles with the includes.Just some advice, this will plague you for some time to come, severely limit your
future ability to do stuff. Posting at Arduino Forum will help straighten out the issue.
The Wire and Arduino libs are intrinsic to using Arduino, inability to use them will
be like driving a car without an engine.
Just a thought......
--- Updated ---
I think I found possible issue with your includes, that Mellis board lib is almost 10 years old,
last rev. Arduino has probably done 10 revs of their libs since then.
I was able to compile with includes lib I used.
Some board libs for ATTINY recommendations :
Which board manager should I use to work with ATTiny's?
I presently use the following board manager for ATTiny from github: https://mcudude.github.io/MicroCore/package_MCUdude_MicroCore_index.json. But several other board manager can be found on github promising more options/boards support. Like for instance the one by Spence Konde. I am not sure...forum.arduino.cc
I used this one - https://github.com/SpenceKonde/ATTinyCore it has had revisions as recently as 3 months ago
Install :
Then exit and re-enter Arduino, and pick the Konde board lib, install it, and then
pick a choice from this as board.
View attachment 194577
I was able to compile the mBlock project with includes fine.
Last uninstall the mellis lib using boards manager just to insure nothing in it conflicts
with the above ATTINY preferred lib.
Regards, Dana.
hows this?Can you post the project file ? Post it as a zip.
Show your settings and your board selection as well. So I can see the whole picture.
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
void setup() {
pinMode(3,OUTPUT);
pinMode(4,INPUT);
digitalWrite(3,1);
while(1) {
if(digitalRead(4) == 1.000000){
digitalWrite(3,0);
}else{
digitalWrite(3,1);
}
}
}
yes im an idiot. i had resistor connected to pin 1 of the chip not ground. now i have it connected the right way it works as expectedYou sure the R is grounded ? Your button is released ?
What value R is it ?
What do LED connections look like ?
this is why I wrote the "P.S." in post#48i had resistor connected to pin 1 of the chip not ground. now i have it connected the right way it works as expected
thanks.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?