I cant even print to the serial port!

   I am trying to make a touch sensitive keypad with a password. When the correct combination in correct order is given, the lock will get unlocked. I use 2 x TTP223 capacitive touch sensor for test purposes, But I plan to use 14 of them. I use arduino nano for test purposes but will move on to arduino pro mini 5v. 

   I check for every "1" state input pin, then store them all in an array. Later on I check if the given input is already in the entry array. If it is, I skip. If it isnt, I add it. After that I check whether the given combination is true or not.

   I use touch sensors in touch to lock mode, it means that the sensor is latched. When I trigger it, it stays on. When I press again, it turns off. This is why I check whether the input is already in the entry array or not. Unfortunately I dont have a schematic because I couldnt find a good schematic platform. Below is the code and my result in serial port. 


void checkRunes();
void chooseEntry();
void resetInputs();
void checkPassword();
void wakeTheStag();

const static int passSize = 2;
static int LED_VCC = 2; //LEDs are powered from this pin
static int entryCount = 0;

//digital pins

static int servoLeft = 9;
static int servoRight = 10;

//analog pins

static int eyes = 17;

static int password[passSize] = {3,5};
static int defPass[2] = {3,4};
static int entry[passSize] = {0,0};
static int runes[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static bool locked = true;

int count = 0;
int index = 0;

void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, INPUT);
  pinMode(12, INPUT);
  pinMode(13, INPUT);
  pinMode(14, INPUT);
  pinMode(15, INPUT);
  pinMode(16, INPUT);
  pinMode(17, OUTPUT);
  digitalWrite(LED_VCC, HIGH);  

void loop() {



void checkRunes(){
  for(int i = 3; i < 17; i++){
    if(i == servoLeft || i == servoRight || i == eyes || i == 18 || i == 19)
      runes[i] = 0;
    runes[i] = digitalRead(i);      

void chooseEntry(){
  for(int i = 3; i < 17; i++){
    bool found = false;
    for(int j = 3; j < 17; j++){
        if(entry[j] == i){
          found = true;
       entry[entryCount++] = i;

void checkPassword(){
  for(int i = 0; i < passSize; i++){
    if(entry[i] != password[i]){
  locked = false;  

void resetInputs(){
  entryCount == 0;
  digitalWrite(LED_VCC, LOW);
  digitalWrite(LED_VCC, HIGH);

void wakeTheStag(){
  digitalWrite(eyes, HIGH);  


warning I get when I compile:

C:\Users\x\Documents\Arduino\stag0.3\stag0.3.ino: In function 'void resetInputs()':
C:\Users\x\Documents\Arduino\stag0.3\stag0.3.ino:103:14: warning: statement has no effect [-Wunused-value]
C:\Users\x\Documents\Arduino\stag0.3\stag0.3.ino: At global scope:
C:\Users\x\Documents\Arduino\stag0.3\stag0.3.ino:23:12: warning: 'defPass' defined but not used [-Wunused-variable]

Put a simple

Serial.println(F("Hello world"));
delay (100);

Before the closing } of setup()

entryCount == 0;

Is the line that has no effect.
Lose one =

How many LED's are being powered through a single pin? Post the wiring diagram of the LED connections. Just curious if the pin could be overloaded, not related to your posted issue.

"Is the line that has no effect.
Lose one ="

what do you mean by this?

I get this when I implement your first suggestion:

Hello world
00Hello world
00Hello world
00Hello world

Ok, you've got big problems - your device is resetting.
Probably an array issue.

3 leds and 2 sensors for now. It will be 15 leds, 2 servos and 14 sensors. I know its a lot.

I mean use = not ==

ie lose one of the =

oh yeah you right. How can I solve the device resetting problem?

Start debugging.

Im familiar with electronics and programming, but Im new to the arduino IDE. How do I debug?

Hopefully not powering those items directly from a MCU pin.

One example to troubleshooting the issue is through elimination of possibilities.

Got error?

Got error?

Got error?
and so and and so forth.

I do power 3 leds and 3 sensors with just one pin. I think I will use 3-4 pns for the real project. Is it ok?

What does the spec sheet indicate as the proper current restrictions for the MCU you are using?

40mA max

You should limit continuous AVR pin current IN or OUT to 25mA.

A single LED and resistor can draw 5mA and be seen against most indoor lighting. The total current is the issue. With a resistor and a transistor you can use almost no pin current to control a whole lot of power, even higher voltage.

Chip pins are not a hard limit. Cheap devices let you add pins for a loss in speed.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.