Need help with arduino code.?

Alright I asked this question on the arduino forums but nobody is giving me a straight answer, and it's getting annoying. I am using the capsense library on an attiny85, I want to count the number of times an even happens, in this case the capacitive censor exceeding a certain amount. Then based on that number I want it to turn on one led, or two, and so forth, to keep count. Can someone tell me how the f*****g get this to work? I try to use serial to debug and just get "Serial" not defined in this scope. Heres the code: #include #include CapacitiveSensor   cs_1_2 = CapacitiveSensor(1,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired int ledpin = 0; int countnumber = 0; void setup()                    {   cs_1_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example   pinMode (ledpin, OUTPUT); } void loop()                    {   long start = millis();   long total1 =  cs_1_2.capacitiveSensor(30);   if (total1 < 99) {    countnumber == 1;   }   if (countnumber = 1) {     digitalWrite(ledpin, HIGH);   } }

Question by XOIIO 6 years ago  |  last reply 16 days ago

Pin-pointer metal detector front end not working.

Hi,I breadboarded the pin-pointer metal detector and am having trouble with the front end. pcounterA reads 11-14 on the serial port monitor.See previous question on instructibles reproduced below:_________________Asked by jont4e 2 days ago Hi, I bread-boarded your circuit for just the end coils to start, and loaded the sketch. It seems to be pulsing the coil OK but the leds aren't responding nor the buzzer. I uncommented the serial port code and it shows ledthreshold1 always at .97, pcounterA at 12, and calav1 at 81. Is this OK? (The other reported variables are always 1000.) I wound the end coils with some bifilar wire I reclaimed from a microwave HV supply transformer. I assumed that was OK? Do you have a flow chart or description of how the code works so I can troubleshoot? Any help or hints would be greatly appreciated. Jon T 0 Answer from TechKiwi... 2 days ago The pcounterA value should be much higher 200 to 800 at least. My advice is to focus on one channel. Try reversing the polarity of one of the coils as this often is the problem as the pulseIn function needs to have a clean leading edge to trigger the timing process. Ensure your breadboard connections to the coil are short and well grounded. If this does not work direct message me with a link to some photos of your setup and I will try to assist. I'm just building a second unit so your timing is fortuitous as I can provide some test measurements._______________________________Attached are images of the front end scope traces and a shot of the breadboard. Coils are off screen to the left.Swapping coil polarity did not seem to change any waveforms.Hope someone has some suggestions I can try.JT

Topic by jont4e 1 year ago  |  last reply 1 year ago

Anyone with experience with CAN bus + Teensy 3.6?

I have been recently messing around with the Teensy 3.6, of which the MK66FX1M0VMD18 it's rocking is probably one of the most powerful microcontroller I have ever messed with. (180MHz ARM Cortex M4, 256K RAM, hardware FPU, far more than enough GPIO, and an insane amount of serial interfaces!) I am particularly interested in the 2 CAN bus interfaces that it's sporting. However when loading the example code (which explicitly states it is only compatible with the Teensy 3.6! as only it has 2 CAN busses) I have not had much luck getting it to work. I don't really understand what CAN_TX and CAN_RX are suppose to be. I would assume it is simalar to UART where TX is connected to RX and RX is connected to TX. However at least with the MCP2551's I also ordered, the RX (on this chip) is actually an output while the TX appears to be an input. As it turned out, I was not able to use this chip due to it being a strictly 5V logic component. So after having discovered that, I decided to just connect the TX of CAN1 directly to RX on CAN0, and vice versa. Using the Object Oriented CAN example, I get absolutely nothing. If I swap the connections, connecting the low-impedance TX to the other low-impedance TX, and RX to RX, I also get nothing, but if I bring my hand close to the wires, or touch and feel around some of the pins, I will get some packets through and to appear on the serial monitor, almost as if one of the pins is acting as an input and of course it's floating because I don't know which pin that would be, as there is no code or comments to indicate such a button. I honestly have no idea what the hell is going on, and don't have access to a proper scope to see what is going on.

Question by -max- 1 year ago  |  last reply 1 year ago