Jump to content

Arduino stuff/ programing/so cheap


flyingbrick

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.

Link to comment
Share on other sites

  • Replies 416
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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
Link to comment
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.

Link to comment
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 

Link to comment
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?

Link to comment
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. 

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
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!

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...