DS1307, using dayOfWeek value....

I’ve tried everything I can think of (with my limited knowledge), and I can’t seem to get the dayOfWeek value to work with my SWITCH function. I’m creating an INT called whatDayIsIt. When I print this to check on the INT, it’s completely different than the dayOfWeek number. Usual whatDayIsIt returns 10 regardless of the dayOfWeek number returned. Any suggestions? Thanks!

/*************************************************************************
  This is an Arduino library for the Adafruit Thermal Printer.
  Pick one up at --> http://www.adafruit.com/products/597
  These printers use TTL serial to communicate, 2 pins are required.

  Adafruit invests time and resources providing this open source code.
  Please support Adafruit and open-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution.
 *************************************************************************/

// If you're using Arduino 1.0 uncomment the next line:
#include "SoftwareSerial.h"
// If you're using Arduino 23 or earlier, uncomment the next line:
//#include "NewSoftSerial.h"

#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include <avr/pgmspace.h>

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

int printer_RX_Pin = 5;  // This is the green wire
int printer_TX_Pin = 6;  // This is the yellow wire

int buttonState = 0;  // variable for reading the pushbutton status
const int buttonPin = 2;   // the number of the pushbutton pin

char* dayName[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setup(){
    Serial.begin(9600);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();
  
  DateTime now = rtc.now();

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
  
  
  pinMode(7, OUTPUT); digitalWrite(7, LOW); // To also work w/IoTP printer
  printer.begin();

  // The following function calls are in setup(), but do not need to be.
  // Use them anywhere!  They're just here so they're run only one time
  // and not printed over and over.
  // Some functions will feed a line when called to 'solidify' setting.
  // This is normal.
  
    int whatDayIsIt = (now.dayOfWeek(), DEC);
   
    
    printer.println("Date/Time placed into fridge:"); 
    
    printer.justify('C');
    printer.setSize('L');
    printer.boldOn();
  
    printer.println(now.dayOfWeek(), DEC);
    
    printer.println(whatDayIsIt);
    
    switch (whatDayIsIt) {
    case 0:
    printer.println(dayName[0]);
    break;
    case 1:
    printer.println(dayName[1]);
    break;
    case 2:
    printer.println(dayName[2]);
    break;
    case 3:
    printer.println(dayName[3]);
    break;
    case 4:
    printer.println(dayName[4]);
    break;
    case 5:
    printer.println(dayName[5]);
    break;
    case 6:
    printer.println(dayName[6]);
    break;
  }

    printer.boldOff();
  
    printer.print(now.month(), DEC);
    printer.print('/');
    printer.print(now.day(), DEC);
    printer.print('/');
    printer.print(now.year(), DEC);
    printer.println(' ');
    printer.print(now.hour(), DEC);
    printer.print(':');
    printer.print(now.minute(), DEC);
    printer.print(':');
    printer.print(now.second(), DEC);
    printer.println();
    
    
  
  printer.println();
  printer.println();

  printer.sleep();      // Tell printer to sleep
  printer.wake();       // MUST call wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
}


void loop(){
 
  
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {       
  
    DateTime now = rtc.now();
    
    // calculate a date which is 2 days
    DateTime future (now.unixtime() + 2 * 86400L);
    
    
    int whatDayIsIt = (now.dayOfWeek(), DEC);


    switch (whatDayIsIt) {
    case 0:
    printer.println(dayName[0]);
    break;
    case 1:
    printer.println(dayName[1]);
    break;
    case 2:
    printer.println(dayName[2]);
    break;
    case 3:
    printer.println(dayName[3]);
    break;
    case 4:
    printer.println(dayName[4]);
    break;
    case 5:
    printer.println(dayName[5]);
    break;
    case 6:
    printer.println(dayName[6]);
    break;
  }
  
    printer.justify('C');
    printer.setSize('L');
    printer.boldOn();
    
    printer.println(whatDayIsIt);
    printer.println("Toss after this Date/Time:");    
    printer.print(future.month(), DEC);
    printer.print('/');
    printer.print(future.day(), DEC);
    printer.print('/');
    printer.print(future.year(), DEC);
    printer.println(' ');
    printer.print(future.hour(), DEC);
    printer.print(':');
    printer.print(future.minute(), DEC);
    printer.print(':');
    printer.print(future.second(), DEC);
    printer.println();

  
  printer.println();
  printer.println();

  printer.sleep();      // Tell printer to sleep
  printer.wake();       // MUST call wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
  }
}

This line isn't right:

int whatDayIsIt = (now.dayOfWeek(), DEC);

Did you try to convert now.dayOfWeek() into decimal number? Why not int whatDayIsIt=now.dayOfWeek(); ?

Let me give you a hint what your code actually does (print 10 regardless) so you'll remember not to do it:

Serial.print(("A rat", "in Tom's", "house"));

Which one of the three strings gets printed out? Now swap their orders and see which one prints out.

The commas in my example and your code is a C operator. You can read about it:

Thanks so much for the help and the heads up about the comma operator. Everything seems to working now.

Cheers,
~R

You are welcome!

#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2

Can you fine which file contains these definitions? It's a good way to learn your way around the Arduino IDE.