Project Help - Capacitive Touch sensor

Hi guys

I am an absolute beginner and have never used Arduino before. I have ambitiously decided to use Arduino for a uni project. The idea of the project is to use a plant as a controller to trigger sounds using a hand built capacitive sensor, Arduino Uno and the Arduino IDE and Processing software. I have been following the instructions from this blog>>>

I think I have found the correct codes for Arduino and Processing through links to github on this site>>>

I have copied the Arduino code into the IDE software but when I try to run the sketch it sais that 'N' was not declared in this scope. I am also unsure what part of the code on Github I should copy into Processing.

Any help would be greatly appreciated. I understand that I am completely incompetent in this field and have already been berated by experts, so please go easy! I have included a few pictures that may help.



Deceivingly simple looking.

The code the Instructable links to appears incomplete. Pin 9 is set to OUTPUT, but never set HIGH or LOW. It looks like they try to use a timer interrupt for this, but the whole ISR is missing.

It does look like a neat trick.

I think it works like this (skimmed the article, info is thin). L1 and C2 are excited by a block wave generated by pin 9, producing a sine wave between the two. D1 is a half wave rectifier, 1N1418 is a great choice for its fast reverse recovery. R3/C1 are a low pass filter, basically stabilising the voltage coming out of the L1/C2 circuit, and that in turn is read by the A0 and turned into a tone.

Now for your problem: as you forgot to post your code (as in: YOUR code, and do use code tags) can't say anything about it.

Thanks for taking a look. Forgive me, but how do I find out what my code is?

You said you're trying to compile something... that tells me you have some code to work with.

Ah ok. The only codes I have are the ones for Arduino and Processing that I found through the links to Github I posted.

Probably with copy/paste errors. That's why we need to see YOUR actual code. Anyway I suspect it's not doing much of interest, with the sketch not doing anything with pin 9.

Sorry, I see what you mean. I have attached the photos of the code in the IDE.

Please go and read the sticky on how to post code. Screenshots are possibly the worst way. The IDE even offers a "copy for forum" function for this!

void setup() {
  TCCR1A=0b10000010;        //-Set up frequency generator
  TCCR1B=0b00011001;        //-+

  pinMode(9,OUTPUT);        //-Signal generator pin
  pinMode(8,OUTPUT);        //-Sync (test) pin


  for(int i=0;i<N;i++)      //-Preset results
    results[i]=0;         //-+


void loop() {
   unsigned int d;

  int counter = 0;
  for(unsigned int d=0;d<N;d++)
    int v=analogRead(0);    //-Read response signal
    CLR(TCCR1B,0);          //-Stop generator
    TCNT1=0;                //-Reload new frequency
    ICR1=d;                 // |
    OCR1A=d/2;              //-+
    SET(TCCR1B,0);          //-Restart generator

    results[d]=results[d]*0.5+(float)(v)*0.5; //Filter results
    freq[d] = d;

 //   plot(v,0);              //-Display
 //   plot(results[d],1);
  // delayMicroseconds(1);

That code is incomplete. Several variables are not declared - it seems you missed part of the code as posted in the links you gave, which do have some variable declarations at the top. That includes N, but also a few others.

Thanks, will check thoroughly and try again

Nice one wvmarle, it seems I was only copying the bit of the code directly for the void setup and the void loop. All verified now. Thanks