flyingbrick

Arduino stuff/ programing/so cheap

Recommended Posts

5 hours ago, Ghostchips said:

I looked at the examples and got a bunch of error codes when i tried to make it function.
 

I don't even know what a stray slashNumber is..

Pretty sure the pages of reference is where i got this unusable code from.  "How hard could it be, that guy down south made his dashboard indicator light controller in one night".  Turns out it's impossible.  And now everyone will know i'm dumber than shit & shouldn't exist.

Problem is the extra semicolons at the end of the if lines (sorry I didn't spot it earlier).

Did you get any of the standard examples working? It's a really good place to start.

Share this post


Link to post
Share on other sites

Also, programming,  you have to get everything right, so easier to start small, get it going, then change one thing at a time.

Share this post


Link to post
Share on other sites

Yup, blink is easy. Reprogramming it to morse code was easy, string of lights blinking at different rates was easy. One sensor that activates one relay was easy.  Multi sensors, not yet.

Share this post


Link to post
Share on other sites
3 hours ago, Ghostchips said:

Yup, blink is easy. Reprogramming it to morse code was easy, string of lights blinking at different rates was easy. One sensor that activates one relay was easy.  Multi sensors, not yet.

Merry Christmas:

const int sensorPin1 = A1;
const int sensorPin2 = A2;
const int sensorPin3 = A3;
int sensorValue = 0;

int sensorThreshold = 900;
int sensorMax = 0; 

void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
}

void flashIfHigh(uint8_t inPin, uint8_t outPin)
{
	if (analogRead(inPin) >= sensorThreshold)
	{
		digitalWrite(outPin, !(digitalRead(outPin)));
	}
	else
	{
		digitalWrite(outPin, LOW);
	}
}

void loop()
{
	delay(200);

	flashIfHigh(sensorPin1, 2);
	flashIfHigh(sensorPin2, 3);
	flashIfHigh(sensorPin3, 4);
}

 

  • Like 2

Share this post


Link to post
Share on other sites

It's a Christmas programming miracle!


Now to add variables that speed up the delay based on prior input repetition.
...and i have enough spare parts to make an electronic injector system... Hmm..

  • Like 4

Share this post


Link to post
Share on other sites

I noticed that when the magnet hovers over the sensor the output pulses over & over.  For my application this time that's not a problem and i can make it an advantage.  For other things there might be something required to make it pulse once only.  Sounds simple but i bet it'll need massive restructure of the code.

Share this post


Link to post
Share on other sites

What do you mean by pulses? Is it a tach signal or wheel speed or something? Might be easier for you to explain the whole project :-D

also.. isnt it satisfying when shit works :-D

  • Like 1

Share this post


Link to post
Share on other sites

Ok I'm not sure if someone will know the answer but here goes.

I need a thing to count how many packs are being processed per min and displayed on a screen. I can get the trigger or pulses easily off the machine. But then would need a unit or program to display this as a number per min. I would need to display the last minutes product while counting the next one and so on. Any ideas? Cheers rusty 

Share this post


Link to post
Share on other sites
24 minutes ago, IvyMike said:

If you get yourself an Arduino and a basic display (LCD1602 or similar) that shouldn't be hard to accomplish. If you use something like this as a guide: https://www.youtube.com/watch?v=dZZynJLmTn8 it should help you get on your feet.

 

Sweet as cheers for the info. I'd like to display the info on a small tv screen say 19inch. Dies that change anything?

Share this post


Link to post
Share on other sites
2 minutes ago, rusty360 said:

Sweet as cheers for the info. I'd like to display the info on a small tv screen say 19inch. Dies that change anything?

Yeah, Arduino isn't really VGA/HDMI friendly. It might pay to use a Raspberry Pi instead. Youtube has loads of tutorials for those as well. 

Share this post


Link to post
Share on other sites

theres a video chip you can still get from china. Max7456 or something like that. It's on all quadcopter OSDs... so you could buy a minimOSD for $10 and reprogram that to do what you want is you really want a composite video signal for a big screen? or just build/buy a large 7 seg display? 

  • Like 1

Share this post


Link to post
Share on other sites
On 07/01/2019 at 09:49, Ned said:

theres a video chip you can still get from china. Max7456 or something like that. It's on all quadcopter OSDs... so you could buy a minimOSD for $10 and reprogram that to do what you want is you really want a composite video signal for a big screen? or just build/buy a large 7 seg display? 

I'm thinking raspberry pi is ticket as I can just plug a computer screen in and go. I've just gotta learn how to write the program now!! And pick what model pi to buy!

Share this post


Link to post
Share on other sites

Was trying to think of a way to make the function names stand out a bit better when scrolling up and down through lots of code.

Found an ascii font generator. It's glorious.

Capture.PNG.4cdbcdeb37f7acb59077159a0bb0524b.PNG

  • Like 5

Share this post


Link to post
Share on other sites

looks good. Just a couple tips (some controversial and waiting for @h4nd to tell me im wrong :P )
replace if (IncrementCounter == 9000) { IncrementCounter = 0; } with >= 9000 so it still works if it ever skips 9000.
I know it wont skip 9000, but there is a reasonable chance that at some point you'll be like "fuck, this takes ages, i wonder how the thing looks when i increase the values heaps and fast?" and change the IncrementCounter = IncrementCounter + 1; to IncrementCounter = IncrementCounter + 5; just for kicks, and then shit will no longer work right :)

and second, your variable naming techniques ;) this is the controversial part as everyone has their own standard... but most people will start their variable names with a lower case, so its easy to differentiate from function names.

so IncrementCounter to most looks like a function, whereas incrementCounter would be a variable.

It's especially handy in IDEs like the arduino one as it doesnt do auto complete and function complete things etc, so it just reads a bit easier and helps you make less mistakes.

  • Like 3
  • Haha 1

Share this post


Link to post
Share on other sites

Aahhh yes I've noticed that people start with lower case for first letter but didnt know why. (As it seems easier for me to read with upper) 

But that makes sense. Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now